package prbase;

import java.awt.CardLayout;
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;

public class MainFrame extends javax.swing.JFrame {

    private DocumentListener TextListener = new DocumentListener() {

        public void insertUpdate(DocumentEvent e) {
            FilterTreeModel ftm = (FilterTreeModel) jTree1.getModel();
            ftm.setFilterText(jTextField1.getText());
            for (int i = 0; i < jTree1.getRowCount(); i++) {
                jTree1.expandRow(i);
            }
            System.out.println("iu: " + jTextField1.getText());
        }

        public void removeUpdate(DocumentEvent e) {
            FilterTreeModel ftm = (FilterTreeModel) jTree1.getModel();
            ftm.setFilterText(jTextField1.getText());
            if (jTextField1.getText().length() > 0) {
                for (int i = 0; i < jTree1.getRowCount(); i++) {
                    jTree1.expandRow(i);
                }
            }
            System.out.println("ru: " + jTextField1.getText());
        }

        public void changedUpdate(DocumentEvent e) {
            System.out.println("cu: " + jTextField1.getText());
        }
    };

    private class FilterTreeModel implements TreeModel {

        Filter _filter = new Filter();
        DefaultTreeModel _model;

        public FilterTreeModel(DefaultMutableTreeNode root) {
            _model = new DefaultTreeModel(root);
        }

        public void setFilterText(String text) {
            _filter.setFilterText(text);

            DefaultMutableTreeNode root = (DefaultMutableTreeNode) _model.getRoot();

            int[] childIndices = new int[root.getChildCount()];
            Object[] children = new Object[root.getChildCount()];
            for (int i = 0; i < root.getChildCount(); i++) {
                childIndices[i] = i;
                children[i] = root.getChildAt(i);
            }

            _model.nodeStructureChanged(root);
        }

        public void expandAll() {
            this.expandAll();
        }

        public Object getChild(Object parent, int index) {

            int cnt = -1;
            for (int i = 0; i < _model.getChildCount(parent); i++) {
                Object childObj = _model.getChild(parent, i);
                if (hasFilteredChildren(childObj)) {
                    cnt++;
                }

                if (cnt == index) {
                    return childObj;
                }
            }

            return null;
        }

        public int getChildCount(Object parent) {
            if (hasFilteredChildren(parent)) {
                return getfilteredChildCount(parent);
            }

            return 0;
        }

        public boolean hasFilteredChildren(Object parent) {
            int realCount = _model.getChildCount(parent);

            if (realCount == 0) {
                return _filter.pass(parent);
            }

            for (int i = 0; i < realCount; i++) {
                DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) _model.getChild(parent, i);
                if (hasFilteredChildren(dmtn)) {
                    return true;
                }
            }

            return _filter.pass(parent);
        }

        public int getfilteredChildCount(Object parent) {
            int realCount = _model.getChildCount(parent);
            int filterCount = 0;

            for (int i = 0; i < realCount; i++) {
                DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode) _model.getChild(parent, i);
                if (hasFilteredChildren(dmtn)) {
                    filterCount++;
                }
            }

            return filterCount;
        }

        public void addTreeModelListener(TreeModelListener l) {
            _model.addTreeModelListener(l);
        }

        public int getIndexOfChild(Object parent, Object child) {
            return _model.getIndexOfChild(parent, child);
        }

        public Object getRoot() {
            return _model.getRoot();
        }

        public boolean isLeaf(Object node) {
            return _model.isLeaf(node);
        }

        public void removeTreeModelListener(TreeModelListener l) {
            _model.removeTreeModelListener(l);
        }

        public void valueForPathChanged(TreePath path, Object newValue) {
            _model.valueForPathChanged(path, newValue);
        }

        public void insertNodeInto(DefaultMutableTreeNode dmtn, DefaultMutableTreeNode root, int index) {
            _model.insertNodeInto(dmtn, root, index);
        }

        public void removeNodeFromParent(DefaultMutableTreeNode dmtn) {
            _model.removeNodeFromParent(dmtn);
        }

        public void nodeChanged(DefaultMutableTreeNode dmtn) {
            _model.nodeChanged(dmtn);
        }
    }

    class Filter {

        String _text = "";

        public void setFilterText(String text) {
            _text = text;
        }

        public boolean pass(Object obj) {
            if (_text.length() <= 0) {
                return true;
            }

            return obj.toString().toUpperCase().startsWith(_text.toUpperCase());
        }
    }

//    private class FiltredTreeModel extends DefaultTreeModel {
//
//        public FiltredTreeModel(TreeNode root) {
//            super(root);
//        }
//
//        @Override
//        public Object getChild(Object parent, int index) {
//            if (jTextField1.getText().length() == 0) {
//                return super.getChild(parent, index);
//            }
//            return super.getChild(parent, index);
//        }
//
//        @Override
//        public int getChildCount(Object parent) {
//            return super.getChildCount(parent);
//        }
//    }
    private static class itemSelected {

        static Integer itemType = 0;
        static Integer itemID = 0;

        /*
         * itemType:
         * + 0 - top
         * ++ 1 - Проект
         * + 11 - пункт ТЗ и Сметы в проекте
         * ++ 111 - ТЗ
         * ++ 112 - Смета
         * + 12 - пункт Оборудование в проекте
         * ++ 121 - Спецификация
         * + 1211 - пункт Счета
         * ++ 12111 - Счет
         * ++ 121111 - ТТН
         * + 1212 - пункт Ведомости
         * ++ 12121 - Ведомость
         * + 13 - пункт Объекты в проекте
         * ++ 131 - Объект
         * + 1311 - пункт Сметы
         * ++ то же, что и Смета в проекте - 112
         * + 1312 - пункт Оборудование объекта
         * ++ то же, что и Спецификация в проекте 121
         * + то же, что и пункт Счета в проекте 1211
         * ++ то же, что и Счет в проекте 12111
         * ++ то же, что и ТТН в проекте 121111
         * + то же, что и пункт Ведомости в проекте 1212
         * ++ то же, что и Ведомость в проекте 12121
         * + 1313 - пункт Работа
         * ++ 13131 - Схема
         * + 1314 - пункт Щиты
         * ++ 13141 - Щит
         * ++ 131411 - Чертеж
         */
    }

    public MainFrame() {
        initComponents();
        this.setMinimumSize(this.getSize());
        this.setTitle(Vars.getVersion());
        //jTree1.setCellRenderer(new ProjTreeRenderer());
        jTextField1.getDocument().addDocumentListener(TextListener);
        RefreshProjects();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopupMenu1 = new javax.swing.JPopupMenu();
        jMenuItem9 = new javax.swing.JMenuItem();
        jPopupMenu2 = new javax.swing.JPopupMenu();
        jMenuItem10 = new javax.swing.JMenuItem();
        jPopupMenu3 = new javax.swing.JPopupMenu();
        jMenuItem11 = new javax.swing.JMenuItem();
        jPopupMenu4 = new javax.swing.JPopupMenu();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenuItem13 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();
        jSeparator5 = new javax.swing.JSeparator();
        jMenuItem27 = new javax.swing.JMenuItem();
        jMenuItem28 = new javax.swing.JMenuItem();
        jPopupMenu5 = new javax.swing.JPopupMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem15 = new javax.swing.JMenuItem();
        jMenuItem19 = new javax.swing.JMenuItem();
        jMenuItem20 = new javax.swing.JMenuItem();
        jPopupMenu6 = new javax.swing.JPopupMenu();
        jMenuItem18 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jPopupMenu7 = new javax.swing.JPopupMenu();
        jMenuItem21 = new javax.swing.JMenuItem();
        jPopupMenu8 = new javax.swing.JPopupMenu();
        jMenuItem22 = new javax.swing.JMenuItem();
        jMenuItem23 = new javax.swing.JMenuItem();
        jMenuItem24 = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JSeparator();
        jMenuItem25 = new javax.swing.JMenuItem();
        jPopupMenu9 = new javax.swing.JPopupMenu();
        jMenuItem26 = new javax.swing.JMenuItem();
        jPopupMenu10 = new javax.swing.JPopupMenu();
        jMenuItem29 = new javax.swing.JMenuItem();
        jPopupMenu11 = new javax.swing.JPopupMenu();
        jMenuItem30 = new javax.swing.JMenuItem();
        jPopupMenu12 = new javax.swing.JPopupMenu();
        jMenuItem31 = new javax.swing.JMenuItem();
        jPopupMenu13 = new javax.swing.JPopupMenu();
        jMenuItem32 = new javax.swing.JMenuItem();
        jPopupMenu14 = new javax.swing.JPopupMenu();
        jMenuItem33 = new javax.swing.JMenuItem();
        jPopupMenu15 = new javax.swing.JPopupMenu();
        jMenuItem34 = new javax.swing.JMenuItem();
        jPopupMenu16 = new javax.swing.JPopupMenu();
        jMenuItem16 = new javax.swing.JMenuItem();
        jMenuItem17 = new javax.swing.JMenuItem();
        jMenuItem35 = new javax.swing.JMenuItem();
        jSeparator11 = new javax.swing.JSeparator();
        jMenuItem39 = new javax.swing.JMenuItem();
        jSeparator9 = new javax.swing.JSeparator();
        jMenuItem41 = new javax.swing.JMenuItem();
        jSeparator10 = new javax.swing.JSeparator();
        jMenuItem40 = new javax.swing.JMenuItem();
        jPopupMenu17 = new javax.swing.JPopupMenu();
        jMenuItem36 = new javax.swing.JMenuItem();
        jMenuItem37 = new javax.swing.JMenuItem();
        jMenuItem38 = new javax.swing.JMenuItem();
        jPopupMenu18 = new javax.swing.JPopupMenu();
        jMenuItem42 = new javax.swing.JMenuItem();
        jMenuItem43 = new javax.swing.JMenuItem();
        jMenuItem44 = new javax.swing.JMenuItem();
        jPopupMenu19 = new javax.swing.JPopupMenu();
        jMenuItem45 = new javax.swing.JMenuItem();
        jMenuItem46 = new javax.swing.JMenuItem();
        jMenuItem47 = new javax.swing.JMenuItem();
        jPopupMenu20 = new javax.swing.JPopupMenu();
        jMenuItem48 = new javax.swing.JMenuItem();
        jMenuItem49 = new javax.swing.JMenuItem();
        jMenuItem50 = new javax.swing.JMenuItem();
        jPopupMenu21 = new javax.swing.JPopupMenu();
        jMenuItem51 = new javax.swing.JMenuItem();
        jMenuItem52 = new javax.swing.JMenuItem();
        jMenuItem53 = new javax.swing.JMenuItem();
        jPopupMenu22 = new javax.swing.JPopupMenu();
        jMenuItem54 = new javax.swing.JMenuItem();
        jMenuItem55 = new javax.swing.JMenuItem();
        jMenuItem56 = new javax.swing.JMenuItem();
        jPopupMenu23 = new javax.swing.JPopupMenu();
        jMenuItem57 = new javax.swing.JMenuItem();
        jMenuItem59 = new javax.swing.JMenuItem();
        jPopupMenu24 = new javax.swing.JPopupMenu();
        jMenuItem58 = new javax.swing.JMenuItem();
        jMenuItem60 = new javax.swing.JMenuItem();
        jMenuItem61 = new javax.swing.JMenuItem();
        jPopupMenu25 = new javax.swing.JPopupMenu();
        jMenuItem62 = new javax.swing.JMenuItem();
        jMenuItem63 = new javax.swing.JMenuItem();
        jMenuItem64 = new javax.swing.JMenuItem();
        jPopupMenu26 = new javax.swing.JPopupMenu();
        jMenuItem65 = new javax.swing.JMenuItem();
        jMenuItem66 = new javax.swing.JMenuItem();
        jMenuItem67 = new javax.swing.JMenuItem();
        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTree1 = new javax.swing.JTree();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jSeparator6 = new javax.swing.JSeparator();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jSeparator7 = new javax.swing.JSeparator();
        jButton3 = new javax.swing.JButton();
        jTextField7 = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jTextField12 = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jTextField8 = new javax.swing.JTextField();
        jButton5 = new javax.swing.JButton();
        jTextField9 = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();
        jSeparator3 = new javax.swing.JSeparator();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jTextField13 = new javax.swing.JTextField();
        jPanel9 = new javax.swing.JPanel();
        jTextField10 = new javax.swing.JTextField();
        jButton8 = new javax.swing.JButton();
        jTextField11 = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextArea3 = new javax.swing.JTextArea();
        jSeparator8 = new javax.swing.JSeparator();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jTextField14 = new javax.swing.JTextField();
        jPanel10 = new javax.swing.JPanel();
        jSeparator12 = new javax.swing.JSeparator();
        jTextField15 = new javax.swing.JTextField();
        jButton11 = new javax.swing.JButton();
        jTextField16 = new javax.swing.JTextField();
        jTextField17 = new javax.swing.JTextField();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTextArea4 = new javax.swing.JTextArea();
        jPanel11 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jPanel12 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jPanel13 = new javax.swing.JPanel();
        jTextField18 = new javax.swing.JTextField();
        jButton14 = new javax.swing.JButton();
        jTextField19 = new javax.swing.JTextField();
        jSeparator13 = new javax.swing.JSeparator();
        jTextField20 = new javax.swing.JTextField();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTextArea5 = new javax.swing.JTextArea();
        jPanel14 = new javax.swing.JPanel();
        jTextField21 = new javax.swing.JTextField();
        jButton17 = new javax.swing.JButton();
        jTextField22 = new javax.swing.JTextField();
        jSeparator14 = new javax.swing.JSeparator();
        jTextField23 = new javax.swing.JTextField();
        jButton18 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTextArea6 = new javax.swing.JTextArea();
        jPanel15 = new javax.swing.JPanel();
        jTextField24 = new javax.swing.JTextField();
        jButton20 = new javax.swing.JButton();
        jTextField25 = new javax.swing.JTextField();
        jSeparator15 = new javax.swing.JSeparator();
        jTextField26 = new javax.swing.JTextField();
        jButton21 = new javax.swing.JButton();
        jButton22 = new javax.swing.JButton();
        jScrollPane8 = new javax.swing.JScrollPane();
        jTextArea7 = new javax.swing.JTextArea();
        jPanel16 = new javax.swing.JPanel();
        jTextField27 = new javax.swing.JTextField();
        jSeparator16 = new javax.swing.JSeparator();
        jTextField29 = new javax.swing.JTextField();
        jButton24 = new javax.swing.JButton();
        jButton25 = new javax.swing.JButton();
        jScrollPane9 = new javax.swing.JScrollPane();
        jTextArea8 = new javax.swing.JTextArea();
        jPanel17 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        jPanel18 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jPanel19 = new javax.swing.JPanel();
        jLabel18 = new javax.swing.JLabel();
        jPanel20 = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        jPanel21 = new javax.swing.JPanel();
        jTextField28 = new javax.swing.JTextField();
        jButton23 = new javax.swing.JButton();
        jTextField30 = new javax.swing.JTextField();
        jSeparator17 = new javax.swing.JSeparator();
        jTextField31 = new javax.swing.JTextField();
        jButton26 = new javax.swing.JButton();
        jButton27 = new javax.swing.JButton();
        jScrollPane10 = new javax.swing.JScrollPane();
        jTextArea9 = new javax.swing.JTextArea();
        jPanel22 = new javax.swing.JPanel();
        jTextField32 = new javax.swing.JTextField();
        jButton28 = new javax.swing.JButton();
        jTextField33 = new javax.swing.JTextField();
        jSeparator18 = new javax.swing.JSeparator();
        jTextField34 = new javax.swing.JTextField();
        jButton29 = new javax.swing.JButton();
        jButton30 = new javax.swing.JButton();
        jScrollPane11 = new javax.swing.JScrollPane();
        jTextArea10 = new javax.swing.JTextArea();
        jPanel23 = new javax.swing.JPanel();
        jTextField35 = new javax.swing.JTextField();
        jButton31 = new javax.swing.JButton();
        jTextField36 = new javax.swing.JTextField();
        jSeparator19 = new javax.swing.JSeparator();
        jTextField37 = new javax.swing.JTextField();
        jButton32 = new javax.swing.JButton();
        jButton33 = new javax.swing.JButton();
        jScrollPane12 = new javax.swing.JScrollPane();
        jTextArea11 = new javax.swing.JTextArea();
        jTextField1 = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();

        jMenuItem9.setText("Создать проект...");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jPopupMenu1.add(jMenuItem9);

        jMenuItem10.setText("Добавить спецификацию оборудования...");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jPopupMenu2.add(jMenuItem10);

        jMenuItem11.setText("Добавить объект...");
        jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem11ActionPerformed(evt);
            }
        });
        jPopupMenu3.add(jMenuItem11);

        jMenuItem12.setText("Открыть");
        jPopupMenu4.add(jMenuItem12);

        jMenuItem13.setText("Переименовать");
        jPopupMenu4.add(jMenuItem13);

        jMenuItem14.setText("Удалить");
        jPopupMenu4.add(jMenuItem14);
        jPopupMenu4.add(jSeparator5);

        jMenuItem27.setText("Добавить счет...");
        jPopupMenu4.add(jMenuItem27);

        jMenuItem28.setText("Добавить ведомость смонтированного оборудования...");
        jPopupMenu4.add(jMenuItem28);

        jMenuItem7.setText("Добавить техническое задание...");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jPopupMenu5.add(jMenuItem7);

        jMenuItem15.setText("Добавить смету...");
        jPopupMenu5.add(jMenuItem15);

        jMenuItem19.setText("Добавить спецификацию оборудования...");
        jPopupMenu5.add(jMenuItem19);

        jMenuItem20.setText("Добавить объект...");
        jPopupMenu5.add(jMenuItem20);

        jMenuItem18.setText("Добавить техническое задание...");
        jMenuItem18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem18ActionPerformed(evt);
            }
        });
        jPopupMenu6.add(jMenuItem18);

        jMenuItem6.setText("Добавить смету...");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jPopupMenu6.add(jMenuItem6);

        jMenuItem21.setText("Добавить смету...");
        jMenuItem21.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem21ActionPerformed(evt);
            }
        });
        jPopupMenu7.add(jMenuItem21);

        jMenuItem22.setText("Открыть");
        jPopupMenu8.add(jMenuItem22);

        jMenuItem23.setText("Переименовать");
        jPopupMenu8.add(jMenuItem23);

        jMenuItem24.setText("Удалить");
        jPopupMenu8.add(jMenuItem24);
        jPopupMenu8.add(jSeparator4);

        jMenuItem25.setText("Добавить смету...");
        jPopupMenu8.add(jMenuItem25);

        jMenuItem26.setText("Добавить спецификацию оборудования...");
        jMenuItem26.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem26ActionPerformed(evt);
            }
        });
        jPopupMenu9.add(jMenuItem26);

        jMenuItem29.setText("Добавить счет...");
        jMenuItem29.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem29ActionPerformed(evt);
            }
        });
        jPopupMenu10.add(jMenuItem29);

        jMenuItem30.setText("Добавить ведомость смонтированного оборудования...");
        jMenuItem30.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem30ActionPerformed(evt);
            }
        });
        jPopupMenu11.add(jMenuItem30);

        jMenuItem31.setText("Добавить ТТН");
        jMenuItem31.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem31ActionPerformed(evt);
            }
        });
        jPopupMenu12.add(jMenuItem31);

        jMenuItem32.setText("Добавить схему...");
        jMenuItem32.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem32ActionPerformed(evt);
            }
        });
        jPopupMenu13.add(jMenuItem32);

        jMenuItem33.setText("Добавить щит...");
        jMenuItem33.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem33ActionPerformed(evt);
            }
        });
        jPopupMenu14.add(jMenuItem33);

        jMenuItem34.setText("Добавить чертеж...");
        jMenuItem34.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem34ActionPerformed(evt);
            }
        });
        jPopupMenu15.add(jMenuItem34);

        jMenuItem16.setText("Переименовать проект...");
        jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem16ActionPerformed(evt);
            }
        });
        jPopupMenu16.add(jMenuItem16);

        jMenuItem17.setText("Шифр и номер...");
        jMenuItem17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem17ActionPerformed(evt);
            }
        });
        jPopupMenu16.add(jMenuItem17);

        jMenuItem35.setText("Адрес...");
        jMenuItem35.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem35ActionPerformed(evt);
            }
        });
        jPopupMenu16.add(jMenuItem35);
        jPopupMenu16.add(jSeparator11);

        jMenuItem39.setText("Текст договора...");
        jMenuItem39.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem39ActionPerformed(evt);
            }
        });
        jPopupMenu16.add(jMenuItem39);
        jPopupMenu16.add(jSeparator9);

        jMenuItem41.setText("Даты и цены...");
        jMenuItem41.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem41ActionPerformed(evt);
            }
        });
        jPopupMenu16.add(jMenuItem41);
        jPopupMenu16.add(jSeparator10);

        jMenuItem40.setText("Примечания...");
        jMenuItem40.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem40ActionPerformed(evt);
            }
        });
        jPopupMenu16.add(jMenuItem40);

        jMenuItem36.setText("Переименовать...");
        jMenuItem36.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem36ActionPerformed(evt);
            }
        });
        jPopupMenu17.add(jMenuItem36);

        jMenuItem37.setText("Документ...");
        jMenuItem37.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem37ActionPerformed(evt);
            }
        });
        jPopupMenu17.add(jMenuItem37);

        jMenuItem38.setText("Примечания...");
        jMenuItem38.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem38ActionPerformed(evt);
            }
        });
        jPopupMenu17.add(jMenuItem38);

        jMenuItem42.setText("Переименовать...");
        jMenuItem42.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem42ActionPerformed(evt);
            }
        });
        jPopupMenu18.add(jMenuItem42);

        jMenuItem43.setText("Документ...");
        jMenuItem43.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem43ActionPerformed(evt);
            }
        });
        jPopupMenu18.add(jMenuItem43);

        jMenuItem44.setText("Примечания...");
        jMenuItem44.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem44ActionPerformed(evt);
            }
        });
        jPopupMenu18.add(jMenuItem44);

        jMenuItem45.setText("Переименовать...");
        jMenuItem45.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem45ActionPerformed(evt);
            }
        });
        jPopupMenu19.add(jMenuItem45);

        jMenuItem46.setText("Документ...");
        jMenuItem46.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem46ActionPerformed(evt);
            }
        });
        jPopupMenu19.add(jMenuItem46);

        jMenuItem47.setText("Примечания...");
        jMenuItem47.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem47ActionPerformed(evt);
            }
        });
        jPopupMenu19.add(jMenuItem47);

        jMenuItem48.setText("Переименовать...");
        jMenuItem48.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem48ActionPerformed(evt);
            }
        });
        jPopupMenu20.add(jMenuItem48);

        jMenuItem49.setText("Документ...");
        jMenuItem49.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem49ActionPerformed(evt);
            }
        });
        jPopupMenu20.add(jMenuItem49);

        jMenuItem50.setText("Примечания...");
        jMenuItem50.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem50ActionPerformed(evt);
            }
        });
        jPopupMenu20.add(jMenuItem50);

        jMenuItem51.setText("Переименовать...");
        jMenuItem51.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem51ActionPerformed(evt);
            }
        });
        jPopupMenu21.add(jMenuItem51);

        jMenuItem52.setText("Документ...");
        jMenuItem52.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem52ActionPerformed(evt);
            }
        });
        jPopupMenu21.add(jMenuItem52);

        jMenuItem53.setText("Примечания...");
        jMenuItem53.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem53ActionPerformed(evt);
            }
        });
        jPopupMenu21.add(jMenuItem53);

        jMenuItem54.setText("Переименовать...");
        jMenuItem54.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem54ActionPerformed(evt);
            }
        });
        jPopupMenu22.add(jMenuItem54);

        jMenuItem55.setText("Документ...");
        jMenuItem55.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem55ActionPerformed(evt);
            }
        });
        jPopupMenu22.add(jMenuItem55);

        jMenuItem56.setText("Примечания...");
        jMenuItem56.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem56ActionPerformed(evt);
            }
        });
        jPopupMenu22.add(jMenuItem56);

        jMenuItem57.setText("Переименовать...");
        jMenuItem57.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem57ActionPerformed(evt);
            }
        });
        jPopupMenu23.add(jMenuItem57);

        jMenuItem59.setText("Примечания...");
        jMenuItem59.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem59ActionPerformed(evt);
            }
        });
        jPopupMenu23.add(jMenuItem59);

        jMenuItem58.setText("Переименовать...");
        jMenuItem58.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem58ActionPerformed(evt);
            }
        });
        jPopupMenu24.add(jMenuItem58);

        jMenuItem60.setText("Документ...");
        jMenuItem60.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem60ActionPerformed(evt);
            }
        });
        jPopupMenu24.add(jMenuItem60);

        jMenuItem61.setText("Примечания...");
        jMenuItem61.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem61ActionPerformed(evt);
            }
        });
        jPopupMenu24.add(jMenuItem61);

        jMenuItem62.setText("Переименовать...");
        jMenuItem62.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem62ActionPerformed(evt);
            }
        });
        jPopupMenu25.add(jMenuItem62);

        jMenuItem63.setText("Фото...");
        jMenuItem63.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem63ActionPerformed(evt);
            }
        });
        jPopupMenu25.add(jMenuItem63);

        jMenuItem64.setText("Примечания...");
        jMenuItem64.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem64ActionPerformed(evt);
            }
        });
        jPopupMenu25.add(jMenuItem64);

        jMenuItem65.setText("Переименовать...");
        jMenuItem65.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem65ActionPerformed(evt);
            }
        });
        jPopupMenu26.add(jMenuItem65);

        jMenuItem66.setText("Документ...");
        jMenuItem66.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem66ActionPerformed(evt);
            }
        });
        jPopupMenu26.add(jMenuItem66);

        jMenuItem67.setText("Примечания...");
        jMenuItem67.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem67ActionPerformed(evt);
            }
        });
        jPopupMenu26.add(jMenuItem67);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jSplitPane1.setBorder(null);
        jSplitPane1.setDividerLocation(350);

        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("/");
        javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Проект 1");
        javax.swing.tree.DefaultMutableTreeNode treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Техническое задание и сметы");
        javax.swing.tree.DefaultMutableTreeNode treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("ТЗ1");
        treeNode3.add(treeNode4);
        treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Смета 1");
        treeNode3.add(treeNode4);
        treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Смета 2");
        treeNode3.add(treeNode4);
        treeNode2.add(treeNode3);
        treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Оборудование");
        treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Спецификации 1");
        javax.swing.tree.DefaultMutableTreeNode treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Счета");
        javax.swing.tree.DefaultMutableTreeNode treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Счет 1");
        javax.swing.tree.DefaultMutableTreeNode treeNode7 = new javax.swing.tree.DefaultMutableTreeNode("ТТН 1");
        treeNode6.add(treeNode7);
        treeNode5.add(treeNode6);
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Счет 2");
        treeNode5.add(treeNode6);
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Счет 3");
        treeNode7 = new javax.swing.tree.DefaultMutableTreeNode("ТТН 3");
        treeNode6.add(treeNode7);
        treeNode5.add(treeNode6);
        treeNode4.add(treeNode5);
        treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Ведомости");
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Ведомость сонтированного оборудования 1");
        treeNode5.add(treeNode6);
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Ведомость сонтированного оборудования 2");
        treeNode5.add(treeNode6);
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Ведомость сонтированного оборудования 3");
        treeNode5.add(treeNode6);
        treeNode4.add(treeNode5);
        treeNode3.add(treeNode4);
        treeNode2.add(treeNode3);
        treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Объекты");
        treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Объект 1");
        treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Сметы объекта");
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Смета 3");
        treeNode5.add(treeNode6);
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Смета 4");
        treeNode5.add(treeNode6);
        treeNode4.add(treeNode5);
        treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Оборудование объекта");
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Спецификации 1");
        treeNode7 = new javax.swing.tree.DefaultMutableTreeNode("Счета");
        javax.swing.tree.DefaultMutableTreeNode treeNode8 = new javax.swing.tree.DefaultMutableTreeNode("Счет 5");
        javax.swing.tree.DefaultMutableTreeNode treeNode9 = new javax.swing.tree.DefaultMutableTreeNode("ТТН 5");
        treeNode8.add(treeNode9);
        treeNode7.add(treeNode8);
        treeNode8 = new javax.swing.tree.DefaultMutableTreeNode("Счет 6");
        treeNode7.add(treeNode8);
        treeNode8 = new javax.swing.tree.DefaultMutableTreeNode("Счет 7");
        treeNode7.add(treeNode8);
        treeNode6.add(treeNode7);
        treeNode7 = new javax.swing.tree.DefaultMutableTreeNode("Ведомости");
        treeNode8 = new javax.swing.tree.DefaultMutableTreeNode("Ведомость сонтированного оборудования 5");
        treeNode7.add(treeNode8);
        treeNode8 = new javax.swing.tree.DefaultMutableTreeNode("Ведомость сонтированного оборудования 6");
        treeNode7.add(treeNode8);
        treeNode8 = new javax.swing.tree.DefaultMutableTreeNode("Ведомость сонтированного оборудования 7");
        treeNode7.add(treeNode8);
        treeNode6.add(treeNode7);
        treeNode5.add(treeNode6);
        treeNode4.add(treeNode5);
        treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Работа");
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Схема 1");
        treeNode5.add(treeNode6);
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Схема 2");
        treeNode5.add(treeNode6);
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Схема 3");
        treeNode5.add(treeNode6);
        treeNode4.add(treeNode5);
        treeNode5 = new javax.swing.tree.DefaultMutableTreeNode("Щиты");
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Щит 1");
        treeNode7 = new javax.swing.tree.DefaultMutableTreeNode("Чертеж 1");
        treeNode6.add(treeNode7);
        treeNode7 = new javax.swing.tree.DefaultMutableTreeNode("Чертеж 2");
        treeNode6.add(treeNode7);
        treeNode5.add(treeNode6);
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Щит 2");
        treeNode5.add(treeNode6);
        treeNode6 = new javax.swing.tree.DefaultMutableTreeNode("Щит 3");
        treeNode7 = new javax.swing.tree.DefaultMutableTreeNode("Чертеж 3");
        treeNode6.add(treeNode7);
        treeNode5.add(treeNode6);
        treeNode4.add(treeNode5);
        treeNode3.add(treeNode4);
        treeNode2.add(treeNode3);
        treeNode1.add(treeNode2);
        jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        jTree1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTree1MouseClicked(evt);
            }
        });
        jTree1.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
                jTree1ValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(jTree1);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE)
        );

        jSplitPane1.setLeftComponent(jPanel1);

        jPanel2.setLayout(new java.awt.CardLayout());

        jLabel2.setText("Проекты");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addContainerGap(559, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel2)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel3, "root");

        jButton1.setText("Открыть документ");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Удалить проект");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jTextField2.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField2.setEditable(false);
        jTextField2.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField2.setText("Название");
        jTextField2.setBorder(null);

        jTextField3.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField3.setEditable(false);
        jTextField3.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField3.setText("Адрес");
        jTextField3.setBorder(null);

        jTextField4.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField4.setEditable(false);
        jTextField4.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField4.setText("Шифр/номер");
        jTextField4.setBorder(null);

        jTextField5.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField5.setEditable(false);
        jTextField5.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField5.setText("Цена");
        jTextField5.setBorder(null);

        jTextField6.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField6.setEditable(false);
        jTextField6.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField6.setText("Предоплата");
        jTextField6.setBorder(null);

        jButton3.setText("Правка...");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jTextField7.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField7.setEditable(false);
        jTextField7.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField7.setText("Примечания:");
        jTextField7.setBorder(null);

        jScrollPane2.setBorder(null);

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setRows(5);
        jTextArea1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane2.setViewportView(jTextArea1);

        jTextField12.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField12.setEditable(false);
        jTextField12.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField12.setText("Имя файла");
        jTextField12.setBorder(null);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jSeparator6, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField7, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jSeparator7, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField6, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField5, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 372, Short.MAX_VALUE)
                        .addComponent(jButton2))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField12, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jTextField12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3)))
        );

        jPanel2.add(jPanel4, "project");

        jLabel4.setText("Технические задания и сметы");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addContainerGap(410, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jLabel4)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel5, "tzs");

        jLabel5.setText("Оборудование");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addContainerGap(516, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jLabel5)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel6, "specs");

        jLabel6.setText("Объекты");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addContainerGap(559, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jLabel6)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel7, "objects");

        jTextField8.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField8.setEditable(false);
        jTextField8.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField8.setText("Название ТЗ");
        jTextField8.setBorder(null);

        jButton5.setText("Открыть документ");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jTextField9.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField9.setEditable(false);
        jTextField9.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField9.setText("Примечания:");
        jTextField9.setBorder(null);

        jScrollPane3.setBorder(null);

        jTextArea2.setColumns(20);
        jTextArea2.setEditable(false);
        jTextArea2.setRows(5);
        jTextArea2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane3.setViewportView(jTextArea2);

        jButton6.setText("Правка...");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setText("Удалить техническое задание");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jTextField13.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField13.setEditable(false);
        jTextField13.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField13.setText("Имя файла");
        jTextField13.setBorder(null);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField8, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jButton5)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField13, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField9, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jButton6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 269, Short.MAX_VALUE)
                        .addComponent(jButton7))))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton5)
                    .addComponent(jTextField13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton6)
                    .addComponent(jButton7)))
        );

        jPanel2.add(jPanel8, "tz");

        jTextField10.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField10.setEditable(false);
        jTextField10.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField10.setText("Название сметы");
        jTextField10.setBorder(null);

        jButton8.setText("Открыть документ");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jTextField11.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField11.setEditable(false);
        jTextField11.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField11.setText("Примечания:");
        jTextField11.setBorder(null);

        jScrollPane4.setBorder(null);

        jTextArea3.setColumns(20);
        jTextArea3.setEditable(false);
        jTextArea3.setRows(5);
        jTextArea3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane4.setViewportView(jTextArea3);

        jButton9.setText("Правка...");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton10.setText("Удалить смету");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jTextField14.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField14.setEditable(false);
        jTextField14.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField14.setText("Имя файла");
        jTextField14.setBorder(null);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField10, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jButton8)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField14, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jSeparator8, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField11, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jButton9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 381, Short.MAX_VALUE)
                        .addComponent(jButton10))))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton8)
                    .addComponent(jTextField14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator8, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton9)
                    .addComponent(jButton10)))
        );

        jPanel2.add(jPanel9, "smeta");

        jTextField15.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField15.setEditable(false);
        jTextField15.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField15.setText("Название спецификации");
        jTextField15.setBorder(null);

        jButton11.setText("Открыть документ");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jTextField16.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField16.setEditable(false);
        jTextField16.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField16.setText("Имя файла");
        jTextField16.setBorder(null);

        jTextField17.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField17.setEditable(false);
        jTextField17.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField17.setText("Примечания:");
        jTextField17.setBorder(null);

        jButton12.setText("Правка...");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jButton13.setText("Удалить спецификацию");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jScrollPane5.setBorder(null);

        jTextArea4.setColumns(20);
        jTextArea4.setEditable(false);
        jTextArea4.setRows(5);
        jTextArea4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane5.setViewportView(jTextArea4);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField15, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addComponent(jButton11)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField16, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jSeparator12, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField17, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addComponent(jButton12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 315, Short.MAX_VALUE)
                        .addComponent(jButton13))))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addComponent(jTextField15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton11)
                    .addComponent(jTextField16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator12, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton12)
                    .addComponent(jButton13)))
        );

        jPanel2.add(jPanel10, "spec");

        jLabel10.setText("Счета");

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10)
                .addContainerGap(580, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addComponent(jLabel10)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel11, "bills");

        jLabel11.setText("Ведомости");

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11)
                .addContainerGap(544, Short.MAX_VALUE))
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addComponent(jLabel11)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel12, "vedomosti");

        jTextField18.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField18.setEditable(false);
        jTextField18.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField18.setText("Название счета");
        jTextField18.setBorder(null);

        jButton14.setText("Открыть документ");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        jTextField19.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField19.setEditable(false);
        jTextField19.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField19.setText("Имя файла");
        jTextField19.setBorder(null);

        jTextField20.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField20.setEditable(false);
        jTextField20.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField20.setText("Примечания:");
        jTextField20.setBorder(null);

        jButton15.setText("Правка...");
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });

        jButton16.setText("Удалить счет");
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });

        jScrollPane6.setBorder(null);

        jTextArea5.setColumns(20);
        jTextArea5.setEditable(false);
        jTextArea5.setRows(5);
        jTextArea5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane6.setViewportView(jTextArea5);

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField18, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addComponent(jButton14)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField19, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jSeparator13, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField20, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel13Layout.createSequentialGroup()
                        .addComponent(jButton15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 391, Short.MAX_VALUE)
                        .addComponent(jButton16))))
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addComponent(jTextField18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton14)
                    .addComponent(jTextField19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator13, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton15)
                    .addComponent(jButton16)))
        );

        jPanel2.add(jPanel13, "bill");

        jTextField21.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField21.setEditable(false);
        jTextField21.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField21.setText("Название ТТН");
        jTextField21.setBorder(null);

        jButton17.setText("Открыть документ");
        jButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton17ActionPerformed(evt);
            }
        });

        jTextField22.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField22.setEditable(false);
        jTextField22.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField22.setText("Имя файла");
        jTextField22.setBorder(null);

        jTextField23.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField23.setEditable(false);
        jTextField23.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField23.setText("Примечания:");
        jTextField23.setBorder(null);

        jButton18.setText("Правка...");
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });

        jButton19.setText("Удалить ТТН");
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });

        jScrollPane7.setBorder(null);

        jTextArea6.setColumns(20);
        jTextArea6.setEditable(false);
        jTextArea6.setRows(5);
        jTextArea6.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane7.setViewportView(jTextArea6);

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField21, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(jButton17)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField22, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jSeparator14, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField23, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel14Layout.createSequentialGroup()
                        .addComponent(jButton18)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 396, Short.MAX_VALUE)
                        .addComponent(jButton19))))
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addComponent(jTextField21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton17)
                    .addComponent(jTextField22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator14, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton18)
                    .addComponent(jButton19)))
        );

        jPanel2.add(jPanel14, "ttn");

        jTextField24.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField24.setEditable(false);
        jTextField24.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField24.setText("Название ведомости");
        jTextField24.setBorder(null);

        jButton20.setText("Открыть документ");
        jButton20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton20ActionPerformed(evt);
            }
        });

        jTextField25.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField25.setEditable(false);
        jTextField25.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField25.setText("Имя файла");
        jTextField25.setBorder(null);

        jTextField26.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField26.setEditable(false);
        jTextField26.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField26.setText("Примечания:");
        jTextField26.setBorder(null);

        jButton21.setText("Правка...");
        jButton21.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton21ActionPerformed(evt);
            }
        });

        jButton22.setText("Удалить ведомость");
        jButton22.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton22ActionPerformed(evt);
            }
        });

        jScrollPane8.setBorder(null);

        jTextArea7.setColumns(20);
        jTextArea7.setEditable(false);
        jTextArea7.setRows(5);
        jTextArea7.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane8.setViewportView(jTextArea7);

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField24, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jButton20)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField25, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jSeparator15, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField26, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jButton21)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 345, Short.MAX_VALUE)
                        .addComponent(jButton22))))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addComponent(jTextField24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton20)
                    .addComponent(jTextField25, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator15, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField26, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton21)
                    .addComponent(jButton22)))
        );

        jPanel2.add(jPanel15, "vedomost");

        jTextField27.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField27.setEditable(false);
        jTextField27.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField27.setText("Название объекта");
        jTextField27.setBorder(null);

        jTextField29.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField29.setEditable(false);
        jTextField29.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField29.setText("Примечания:");
        jTextField29.setBorder(null);

        jButton24.setText("Правка...");
        jButton24.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton24ActionPerformed(evt);
            }
        });

        jButton25.setText("Удалить объект");
        jButton25.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton25ActionPerformed(evt);
            }
        });

        jScrollPane9.setBorder(null);

        jTextArea8.setColumns(20);
        jTextArea8.setEditable(false);
        jTextArea8.setRows(5);
        jTextArea8.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane9.setViewportView(jTextArea8);

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField27, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel16Layout.createSequentialGroup()
                        .addComponent(jButton24)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 372, Short.MAX_VALUE)
                        .addComponent(jButton25))
                    .addComponent(jSeparator16, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField29, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)))
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addComponent(jTextField27, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator16, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField29, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton24)
                    .addComponent(jButton25)))
        );

        jPanel2.add(jPanel16, "object");

        jLabel16.setText("Сметы объекта");

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel16)
                .addContainerGap(513, Short.MAX_VALUE))
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addComponent(jLabel16)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel17, "objsmetas");

        jLabel17.setText("Работа");

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel17)
                .addContainerGap(571, Short.MAX_VALUE))
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addComponent(jLabel17)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel18, "works");

        jLabel18.setText("Щиты");

        javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19);
        jPanel19.setLayout(jPanel19Layout);
        jPanel19Layout.setHorizontalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel18)
                .addContainerGap(580, Short.MAX_VALUE))
        );
        jPanel19Layout.setVerticalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addComponent(jLabel18)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel19, "boxes");

        jLabel19.setText("Оборудование объекта");

        javax.swing.GroupLayout jPanel20Layout = new javax.swing.GroupLayout(jPanel20);
        jPanel20.setLayout(jPanel20Layout);
        jPanel20Layout.setHorizontalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel19)
                .addContainerGap(453, Short.MAX_VALUE))
        );
        jPanel20Layout.setVerticalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addComponent(jLabel19)
                .addContainerGap(458, Short.MAX_VALUE))
        );

        jPanel2.add(jPanel20, "objspecs");

        jTextField28.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField28.setEditable(false);
        jTextField28.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField28.setText("Название схемы");
        jTextField28.setBorder(null);

        jButton23.setText("Открыть документ");
        jButton23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton23ActionPerformed(evt);
            }
        });

        jTextField30.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField30.setEditable(false);
        jTextField30.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField30.setText("Имя файла");
        jTextField30.setBorder(null);

        jTextField31.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField31.setEditable(false);
        jTextField31.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField31.setText("Примечания:");
        jTextField31.setBorder(null);

        jButton26.setText("Правка...");
        jButton26.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton26ActionPerformed(evt);
            }
        });

        jButton27.setText("Удалить схему");
        jButton27.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton27ActionPerformed(evt);
            }
        });

        jScrollPane10.setBorder(null);

        jTextArea9.setColumns(20);
        jTextArea9.setEditable(false);
        jTextArea9.setRows(5);
        jTextArea9.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane10.setViewportView(jTextArea9);

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane10, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField28, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel21Layout.createSequentialGroup()
                        .addComponent(jButton23)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField30, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jSeparator17, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField31, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel21Layout.createSequentialGroup()
                        .addComponent(jButton26)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 381, Short.MAX_VALUE)
                        .addComponent(jButton27))))
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addComponent(jTextField28, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton23)
                    .addComponent(jTextField30, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator17, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField31, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane10, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton26)
                    .addComponent(jButton27)))
        );

        jPanel2.add(jPanel21, "shema");

        jTextField32.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField32.setEditable(false);
        jTextField32.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField32.setText("Название щита");
        jTextField32.setBorder(null);

        jButton28.setText("Открыть документ");
        jButton28.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton28ActionPerformed(evt);
            }
        });

        jTextField33.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField33.setEditable(false);
        jTextField33.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField33.setText("Имя файла");
        jTextField33.setBorder(null);

        jTextField34.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField34.setEditable(false);
        jTextField34.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField34.setText("Примечания:");
        jTextField34.setBorder(null);

        jButton29.setText("Правка...");
        jButton29.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton29ActionPerformed(evt);
            }
        });

        jButton30.setText("Удалить щит");
        jButton30.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton30ActionPerformed(evt);
            }
        });

        jScrollPane11.setBorder(null);

        jTextArea10.setColumns(20);
        jTextArea10.setEditable(false);
        jTextArea10.setRows(5);
        jTextArea10.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane11.setViewportView(jTextArea10);

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField32, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel22Layout.createSequentialGroup()
                        .addComponent(jButton28)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField33, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jSeparator18, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField34, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel22Layout.createSequentialGroup()
                        .addComponent(jButton29)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 394, Short.MAX_VALUE)
                        .addComponent(jButton30))))
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addComponent(jTextField32, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton28)
                    .addComponent(jTextField33, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator18, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField34, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton29)
                    .addComponent(jButton30)))
        );

        jPanel2.add(jPanel22, "box");

        jTextField35.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField35.setEditable(false);
        jTextField35.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField35.setText("Название чертежа");
        jTextField35.setBorder(null);

        jButton31.setText("Открыть документ");
        jButton31.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton31ActionPerformed(evt);
            }
        });

        jTextField36.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField36.setEditable(false);
        jTextField36.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField36.setText("Имя файла");
        jTextField36.setBorder(null);

        jTextField37.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background"));
        jTextField37.setEditable(false);
        jTextField37.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        jTextField37.setText("Примечания:");
        jTextField37.setBorder(null);

        jButton32.setText("Правка...");
        jButton32.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton32ActionPerformed(evt);
            }
        });

        jButton33.setText("Удалить чертеж");
        jButton33.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton33ActionPerformed(evt);
            }
        });

        jScrollPane12.setBorder(null);

        jTextArea11.setColumns(20);
        jTextArea11.setEditable(false);
        jTextArea11.setRows(5);
        jTextArea11.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jScrollPane12.setViewportView(jTextArea11);

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField35, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addComponent(jButton31)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField36, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addComponent(jSeparator19, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jTextField37, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addComponent(jButton32)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 368, Short.MAX_VALUE)
                        .addComponent(jButton33))))
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addComponent(jTextField35, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton31)
                    .addComponent(jTextField36, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator19, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField37, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton32)
                    .addComponent(jButton33)))
        );

        jPanel2.add(jPanel23, "draw");

        jSplitPane1.setRightComponent(jPanel2);

        jLabel1.setText("Фильтр:");

        jButton4.setText("Очистить");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jMenu1.setText("Файл");

        jMenuItem1.setText("Выход");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Вид");

        jMenuItem8.setText("Обновить");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem8);

        jMenuBar1.add(jMenu2);

        jMenu4.setText("Инструменты");

        jMenuItem4.setText("Настройки...");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem4);

        jMenuBar1.add(jMenu4);

        jMenu3.setText("Справка");

        jMenuItem2.setText("О программе...");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem2);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 994, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 814, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton4)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void RefreshProjects() {
        WaitingWindow ww = new WaitingWindow();

        DefaultMutableTreeNode nodeForSelect = null;

        // Добавление проектов
        DefaultMutableTreeNode top = new DefaultMutableTreeNode("Проекты");
        if (itemSelected.itemType.equals(0)) {
            nodeForSelect = top;
        }

        DB db = new DB();
        ResultSet rs = db.getResultSet("SELECT k, name, address, number, code, founddate, prepaydate, enddate, cost, prepay, doclink, notes FROM projects WHERE hide=0");
        try {
            while (rs.next()) {
                Calendar founddate = new GregorianCalendar(0, 0, 0, 0, 0, 0);
                if (rs.getTimestamp("founddate") != null) {
                    founddate.setTimeInMillis(rs.getTimestamp("founddate").getTime());
                }
                Calendar prepaydate = new GregorianCalendar(0, 0, 0, 0, 0, 0);
                try {
                    if (rs.getTimestamp("prepaydate") != null) {
                        prepaydate.setTimeInMillis(rs.getTimestamp("prepaydate").getTime());
                    }
                } catch (SQLException sQLException) {
                }
                Calendar enddate = new GregorianCalendar(0, 0, 0, 0, 0, 0);
                try {
                    if (rs.getTimestamp("enddate") != null) {
                        enddate.setTimeInMillis(rs.getTimestamp("enddate").getTime());
                    }
                } catch (SQLException sQLException) {
                }
                obj_Project prj = new obj_Project(
                        rs.getInt("k"),
                        Vars.getStringFromHex(rs.getString("name")),
                        Vars.getStringFromHex(rs.getString("number")),
                        Vars.getStringFromHex(rs.getString("code")),
                        founddate,
                        prepaydate,
                        enddate,
                        Vars.getStringFromHex(rs.getString("prepay")),
                        Vars.getStringFromHex(rs.getString("cost")),
                        Vars.getStringFromHex(rs.getString("address")),
                        Vars.getStringFromHex(rs.getString("doclink")),
                        Vars.getStringFromHex(rs.getString("notes")));

                DefaultMutableTreeNode prjnode = new DefaultMutableTreeNode(prj);
                top.add(prjnode);
                if (itemSelected.itemType.equals(1) && itemSelected.itemID.equals(prj.k)) {
                    nodeForSelect = prjnode;
                }

                // ТЗ и Сметы
                DefaultMutableTreeNode tzsnode = new DefaultMutableTreeNode("Техническое задание и сметы");
                prjnode.add(tzsnode);
                if (itemSelected.itemType.equals(11) && itemSelected.itemID.equals(prj.k)) {
                    nodeForSelect = tzsnode;
                }

                // ТЗ
                {
                    DB tdb = new DB();
                    ResultSet trs = tdb.getResultSet("SELECT k, projectid, name, notes, doclink FROM tzs WHERE projectid = " + prj.k.toString() + " AND hide = 0");
                    while (trs.next()) {
                        obj_TZ objtz = new obj_TZ(
                                trs.getInt("k"),
                                trs.getInt("projectid"),
                                Vars.getStringFromHex(trs.getString("name")),
                                Vars.getStringFromHex(trs.getString("notes")),
                                Vars.getStringFromHex(trs.getString("doclink")));
                        DefaultMutableTreeNode tznode = new DefaultMutableTreeNode(objtz);
                        tzsnode.add(tznode);
                        if (itemSelected.itemType.equals(111) && itemSelected.itemID.equals(objtz.k)) {
                            nodeForSelect = tznode;
                        }
                    }
                    tdb.closeResultSet();
                }

                //Смета
                {
                    DB tdb = new DB();
                    ResultSet trs = tdb.getResultSet("SELECT k, projectid, objectid, name, notes, doclink FROM smetas WHERE projectid = " + prj.k.toString() + " AND objectid = 0 AND hide = 0");
                    while (trs.next()) {
                        obj_Smeta objsmeta = new obj_Smeta(
                                trs.getInt("k"),
                                trs.getInt("projectid"),
                                trs.getInt("objectid"),
                                Vars.getStringFromHex(trs.getString("name")),
                                Vars.getStringFromHex(trs.getString("notes")),
                                Vars.getStringFromHex(trs.getString("doclink")));
                        DefaultMutableTreeNode smetanode = new DefaultMutableTreeNode(objsmeta);
                        tzsnode.add(smetanode);
                        if (itemSelected.itemType.equals(112) && itemSelected.itemID.equals(objsmeta.k)) {
                            nodeForSelect = smetanode;
                        }
                    }
                    tdb.closeResultSet();
                }

                // Оборудование
                DefaultMutableTreeNode specsnode = new DefaultMutableTreeNode("Оборудование");
                prjnode.add(specsnode);
                if (itemSelected.itemType.equals(12) && itemSelected.itemID.equals(prj.k)) {
                    nodeForSelect = specsnode;
                }

                // Спецификация
                {
                    DB tdb = new DB();
                    ResultSet trs = tdb.getResultSet("SELECT k, name, notes, projectid, objectid, doclink FROM specs WHERE projectid = " + prj.k.toString() + " AND objectid = 0 AND hide = 0");
                    while (trs.next()) {
                        obj_Specs spec = new obj_Specs(
                                trs.getInt("k"),
                                Vars.getStringFromHex(trs.getString("name")),
                                Vars.getStringFromHex(trs.getString("notes")),
                                trs.getInt("projectid"),
                                trs.getInt("objectid"),
                                Vars.getStringFromHex(trs.getString("doclink")));
                        DefaultMutableTreeNode specnode = new DefaultMutableTreeNode(spec);
                        specsnode.add(specnode);
                        if (itemSelected.itemType.equals(121) && itemSelected.itemID.equals(spec.k)) {
                            nodeForSelect = specnode;
                        }

                        // Счета
                        DefaultMutableTreeNode billsnode = new DefaultMutableTreeNode("Счета");
                        specnode.add(billsnode);
                        if (itemSelected.itemType.equals(1211) && itemSelected.itemID.equals(spec.k)) {
                            nodeForSelect = billsnode;
                        }

                        // Счет
                        {
                            DB tdb1 = new DB();
                            ResultSet trs1 = tdb1.getResultSet("SELECT k, specid, name, notes, doclink FROM bills WHERE specid = " + spec.k.toString() + " AND hide = 0");
                            while (trs1.next()) {
                                obj_Bill objbill = new obj_Bill(
                                        trs1.getInt("k"),
                                        trs1.getInt("specid"),
                                        Vars.getStringFromHex(trs1.getString("name")),
                                        Vars.getStringFromHex(trs1.getString("notes")),
                                        Vars.getStringFromHex(trs1.getString("doclink")));
                                DefaultMutableTreeNode billnode = new DefaultMutableTreeNode(objbill);
                                billsnode.add(billnode);
                                if (itemSelected.itemType.equals(12111) && itemSelected.itemID.equals(objbill.k)) {
                                    nodeForSelect = billnode;
                                }

                                // ТТН
                                {
                                    DB tdb2 = new DB();
                                    ResultSet trs2 = tdb2.getResultSet("SELECT k, billid, name, notes, doclink FROM ttn WHERE billid = " + objbill.k.toString() + " AND hide = 0");
                                    while (trs2.next()) {
                                        obj_TTN objttn = new obj_TTN(
                                                trs2.getInt("k"),
                                                trs2.getInt("billid"),
                                                Vars.getStringFromHex(trs2.getString("name")),
                                                Vars.getStringFromHex(trs2.getString("notes")),
                                                Vars.getStringFromHex(trs2.getString("doclink")));
                                        DefaultMutableTreeNode ttnnode = new DefaultMutableTreeNode(objttn);
                                        billnode.add(ttnnode);
                                        if (itemSelected.itemType.equals(121111) && itemSelected.itemID.equals(objttn.k)) {
                                            nodeForSelect = ttnnode;
                                        }
                                    }
                                    tdb2.closeResultSet();
                                }
                            }
                            tdb1.closeResultSet();
                        }

                        // Ведомости
                        DefaultMutableTreeNode vedomostsnode = new DefaultMutableTreeNode("Ведомости");
                        specnode.add(vedomostsnode);
                        if (itemSelected.itemType.equals(1212) && itemSelected.itemID.equals(spec.k)) {
                            nodeForSelect = vedomostsnode;
                        }

                        // Ведомость
                        {
                            DB tdb1 = new DB();
                            ResultSet trs1 = tdb1.getResultSet("SELECT k, specid, name, notes, doclink FROM vedomosti WHERE specid = " + spec.k.toString() + " AND hide = 0");
                            while (trs1.next()) {
                                obj_Vedomost objvedomost = new obj_Vedomost(
                                        trs1.getInt("k"),
                                        trs1.getInt("specid"),
                                        Vars.getStringFromHex(trs1.getString("name")),
                                        Vars.getStringFromHex(trs1.getString("notes")),
                                        Vars.getStringFromHex(trs1.getString("doclink")));
                                DefaultMutableTreeNode vedomostnode = new DefaultMutableTreeNode(objvedomost);
                                vedomostsnode.add(vedomostnode);
                                if (itemSelected.itemType.equals(12121) && itemSelected.itemID.equals(objvedomost.k)) {
                                    nodeForSelect = vedomostnode;
                                }
                            }
                            tdb1.closeResultSet();
                        }

                    }
                    tdb.closeResultSet();
                }

                // Объекты
                DefaultMutableTreeNode objsnode = new DefaultMutableTreeNode("Объекты");
                prjnode.add(objsnode);
                if (itemSelected.itemType.equals(13) && itemSelected.itemID.equals(prj.k)) {
                    nodeForSelect = objsnode;
                }

                // Объект
                {
                    DB tdb = new DB();
                    ResultSet trs = tdb.getResultSet("SELECT k, name, notes, projectid FROM objects WHERE projectid = " + prj.k.toString() + " AND hide = 0");
                    while (trs.next()) {
                        obj_Objects obj = new obj_Objects(
                                trs.getInt("k"),
                                Vars.getStringFromHex(trs.getString("name")),
                                Vars.getStringFromHex(trs.getString("notes")),
                                trs.getInt("projectid"));
                        DefaultMutableTreeNode objnode = new DefaultMutableTreeNode(obj);
                        objsnode.add(objnode);
                        if (itemSelected.itemType.equals(131) && itemSelected.itemID.equals(obj.k)) {
                            nodeForSelect = objnode;
                        }

                        // Сметы объекта
                        DefaultMutableTreeNode objsmetasnode = new DefaultMutableTreeNode("Сметы объекта");
                        objnode.add(objsmetasnode);
                        if (itemSelected.itemType.equals(1311) && itemSelected.itemID.equals(obj.k)) {
                            nodeForSelect = objsmetasnode;
                        }

                        // Смета объекта
                        {
                            DB tdb1 = new DB();
                            ResultSet trs1 = tdb1.getResultSet("SELECT k, projectid, objectid, name, notes, doclink FROM smetas WHERE projectid = 0 AND objectid = " + obj.k.toString() + " AND hide = 0");
                            while (trs1.next()) {
                                obj_Smeta objobjsmeta = new obj_Smeta(
                                        trs1.getInt("k"),
                                        trs1.getInt("projectid"),
                                        trs1.getInt("objectid"),
                                        Vars.getStringFromHex(trs1.getString("name")),
                                        Vars.getStringFromHex(trs1.getString("notes")),
                                        Vars.getStringFromHex(trs1.getString("doclink")));
                                DefaultMutableTreeNode objsmetanode = new DefaultMutableTreeNode(objobjsmeta);
                                objsmetasnode.add(objsmetanode);
                                if (itemSelected.itemType.equals(112) && itemSelected.itemID.equals(objobjsmeta.k)) {
                                    nodeForSelect = objsmetanode;
                                }
                            }
                            tdb1.closeResultSet();
                        }

                        // Оборудование объекта
                        DefaultMutableTreeNode objspecsnode = new DefaultMutableTreeNode("Оборудование объекта");
                        objnode.add(objspecsnode);
                        if (itemSelected.itemType.equals(1312) && itemSelected.itemID.equals(obj.k)) {
                            nodeForSelect = objspecsnode;
                        }

                        // Спецификация
                        {
                            DB tdb1 = new DB();
                            ResultSet trs1 = tdb1.getResultSet("SELECT k, name, notes, projectid, objectid, doclink FROM specs WHERE projectid = 0 AND objectid = " + obj.k.toString() + " AND hide = 0");
                            while (trs1.next()) {
                                obj_Specs objspec = new obj_Specs(
                                        trs1.getInt("k"),
                                        Vars.getStringFromHex(trs1.getString("name")),
                                        Vars.getStringFromHex(trs1.getString("notes")),
                                        trs1.getInt("projectid"),
                                        trs1.getInt("objectid"),
                                        Vars.getStringFromHex(trs1.getString("doclink")));
                                DefaultMutableTreeNode objspecnode = new DefaultMutableTreeNode(objspec);
                                objspecsnode.add(objspecnode);
                                if (itemSelected.itemType.equals(121) && itemSelected.itemID.equals(objspec.k)) {
                                    nodeForSelect = objspecnode;
                                }

                                // Счета
                                DefaultMutableTreeNode objbillsnode = new DefaultMutableTreeNode("Счета");
                                objspecnode.add(objbillsnode);
                                if (itemSelected.itemType.equals(1211) && itemSelected.itemID.equals(objspec.k)) {
                                    nodeForSelect = objbillsnode;
                                }

                                // Счет
                                {
                                    DB tdb2 = new DB();
                                    ResultSet trs2 = tdb2.getResultSet("SELECT k, specid, name, notes, doclink FROM bills WHERE specid = " + objspec.k.toString() + " AND hide = 0");
                                    while (trs2.next()) {
                                        obj_Bill objbill = new obj_Bill(
                                                trs2.getInt("k"),
                                                trs2.getInt("specid"),
                                                Vars.getStringFromHex(trs2.getString("name")),
                                                Vars.getStringFromHex(trs2.getString("notes")),
                                                Vars.getStringFromHex(trs2.getString("doclink")));
                                        DefaultMutableTreeNode objbillnode = new DefaultMutableTreeNode(objbill);
                                        objbillsnode.add(objbillnode);
                                        if (itemSelected.itemType.equals(12111) && itemSelected.itemID.equals(objbill.k)) {
                                            nodeForSelect = objbillnode;
                                        }

                                        // ТТН
                                        {
                                            DB tdb3 = new DB();
                                            ResultSet trs3 = tdb3.getResultSet("SELECT k, billid, name, notes, doclink FROM ttn WHERE billid = " + objbill.k.toString() + " AND hide = 0");
                                            while (trs3.next()) {
                                                obj_TTN objttn = new obj_TTN(
                                                        trs3.getInt("k"),
                                                        trs3.getInt("billid"),
                                                        Vars.getStringFromHex(trs3.getString("name")),
                                                        Vars.getStringFromHex(trs3.getString("notes")),
                                                        Vars.getStringFromHex(trs3.getString("doclink")));
                                                DefaultMutableTreeNode ttnnode = new DefaultMutableTreeNode(objttn);
                                                objbillnode.add(ttnnode);
                                                if (itemSelected.itemType.equals(121111) && itemSelected.itemID.equals(objttn.k)) {
                                                    nodeForSelect = ttnnode;
                                                }
                                            }
                                            tdb3.closeResultSet();
                                        }
                                    }
                                    tdb2.closeResultSet();
                                }

                                // Ведомости
                                DefaultMutableTreeNode vedomostsnode = new DefaultMutableTreeNode("Ведомости");
                                objspecnode.add(vedomostsnode);
                                if (itemSelected.itemType.equals(1212) && itemSelected.itemID.equals(objspec.k)) {
                                    nodeForSelect = vedomostsnode;
                                }

                                // Ведомость
                                {
                                    DB tdb2 = new DB();
                                    ResultSet trs2 = tdb2.getResultSet("SELECT k, specid, name, notes, doclink FROM vedomosti WHERE specid = " + objspec.k.toString() + " AND hide = 0");
                                    while (trs2.next()) {
                                        obj_Vedomost objvedomost = new obj_Vedomost(
                                                trs2.getInt("k"),
                                                trs2.getInt("specid"),
                                                Vars.getStringFromHex(trs2.getString("name")),
                                                Vars.getStringFromHex(trs2.getString("notes")),
                                                Vars.getStringFromHex(trs2.getString("doclink")));
                                        DefaultMutableTreeNode vedomostnode = new DefaultMutableTreeNode(objvedomost);
                                        vedomostsnode.add(vedomostnode);
                                        if (itemSelected.itemType.equals(12121) && itemSelected.itemID.equals(objvedomost.k)) {
                                            nodeForSelect = vedomostnode;
                                        }
                                    }
                                    tdb2.closeResultSet();
                                }

                            }
                            tdb1.closeResultSet();
                        }

                        // Работа
                        DefaultMutableTreeNode worksnode = new DefaultMutableTreeNode("Работа");
                        objnode.add(worksnode);
                        if (itemSelected.itemType.equals(1313) && itemSelected.itemID.equals(obj.k)) {
                            nodeForSelect = worksnode;
                        }

                        // Схема
                        {
                            DB tdb1 = new DB();
                            ResultSet trs1 = tdb1.getResultSet("SELECT k, objectid, name, notes, doclink FROM shemas WHERE objectid = " + obj.k.toString() + " AND hide = 0");
                            while (trs1.next()) {
                                obj_Shema objshema = new obj_Shema(
                                        trs1.getInt("k"),
                                        trs1.getInt("objectid"),
                                        Vars.getStringFromHex(trs1.getString("name")),
                                        Vars.getStringFromHex(trs1.getString("notes")),
                                        Vars.getStringFromHex(trs1.getString("doclink")));
                                DefaultMutableTreeNode shemanode = new DefaultMutableTreeNode(objshema);
                                worksnode.add(shemanode);
                                if (itemSelected.itemType.equals(13131) && itemSelected.itemID.equals(objshema.k)) {
                                    nodeForSelect = shemanode;
                                }
                            }
                            tdb1.closeResultSet();
                        }

                        // Щиты
                        DefaultMutableTreeNode boxesnode = new DefaultMutableTreeNode("Щиты");
                        objnode.add(boxesnode);
                        if (itemSelected.itemType.equals(1314) && itemSelected.itemID.equals(obj.k)) {
                            nodeForSelect = boxesnode;
                        }

                        // Щит
                        {
                            DB tdb1 = new DB();
                            ResultSet trs1 = tdb1.getResultSet("SELECT k, objectid, name, notes, doclink FROM boxes WHERE objectid = " + obj.k.toString() + " AND hide = 0");
                            while (trs1.next()) {
                                obj_Box objbox = new obj_Box(
                                        trs1.getInt("k"),
                                        trs1.getInt("objectid"),
                                        Vars.getStringFromHex(trs1.getString("name")),
                                        Vars.getStringFromHex(trs1.getString("notes")),
                                        Vars.getStringFromHex(trs1.getString("doclink")));
                                DefaultMutableTreeNode boxnode = new DefaultMutableTreeNode(objbox);
                                boxesnode.add(boxnode);
                                if (itemSelected.itemType.equals(13141) && itemSelected.itemID.equals(objbox.k)) {
                                    nodeForSelect = boxnode;
                                }

                                // Чертеж
                                {
                                    DB tdb2 = new DB();
                                    ResultSet trs2 = tdb2.getResultSet("SELECT k, boxid, name, notes, doclink FROM draws WHERE boxid = " + objbox.k.toString() + " AND hide = 0");
                                    while (trs2.next()) {
                                        obj_Draw objdraw = new obj_Draw(
                                                trs2.getInt("k"),
                                                trs2.getInt("boxid"),
                                                Vars.getStringFromHex(trs2.getString("name")),
                                                Vars.getStringFromHex(trs2.getString("notes")),
                                                Vars.getStringFromHex(trs2.getString("doclink")));
                                        DefaultMutableTreeNode drawnode = new DefaultMutableTreeNode(objdraw);
                                        boxnode.add(drawnode);
                                        if (itemSelected.itemType.equals(131411) && itemSelected.itemID.equals(objdraw.k)) {
                                            nodeForSelect = drawnode;
                                        }
                                    }
                                    tdb2.closeResultSet();
                                }
                            }
                            tdb1.closeResultSet();
                        }

                    }
                    tdb.closeResultSet();
                }
            }
        } catch (SQLException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        db.closeResultSet();

        FilterTreeModel tm = new FilterTreeModel(top);
        jTree1.setModel(tm);

        if (nodeForSelect != null) {
            TreePath tp = new TreePath(nodeForSelect.getPath());
            jTree1.expandPath(tp);
            jTree1.setSelectionPath(tp);
        }

        ww.close();
    }

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        dispose();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        OptionsDialog dlg = new OptionsDialog(this, true);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        itemSelected.itemType = 0;
        itemSelected.itemID = 0;
        RefreshProjects();
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jTree1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree1MouseClicked
        if (evt.getButton() == java.awt.event.MouseEvent.BUTTON2 || evt.getButton() == java.awt.event.MouseEvent.BUTTON3) {
            jTree1.setSelectionPath(jTree1.getPathForLocation(evt.getX(), evt.getY()));
        } else {
            return;
        }

        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }

        if (node.getUserObject().getClass() == String.class) {
            if (node.getUserObject().toString().equals("Проекты")) {
                jPopupMenu1.show(jTree1, evt.getX(), evt.getY());
                return;
            }
            if (node.getUserObject().toString().equals("Оборудование")) {
                jPopupMenu2.show(jTree1, evt.getX(), evt.getY());
                return;
            }
            if (node.getUserObject().toString().equals("Объекты")) {
                jPopupMenu3.show(jTree1, evt.getX(), evt.getY());
                return;
            }
            if (node.getUserObject().toString().equals("Техническое задание и сметы")) {
                jPopupMenu6.show(jTree1, evt.getX(), evt.getY());
                return;
            }
            if (node.getUserObject().toString().equals("Сметы объекта")) {
                jPopupMenu7.show(jTree1, evt.getX(), evt.getY());
                return;
            }
            if (node.getUserObject().toString().equals("Оборудование объекта")) {
                jPopupMenu9.show(jTree1, evt.getX(), evt.getY());
                return;
            }
            if (node.getUserObject().toString().equals("Счета")) {
                jPopupMenu10.show(jTree1, evt.getX(), evt.getY());
                return;
            }
            if (node.getUserObject().toString().equals("Ведомости")) {
                jPopupMenu11.show(jTree1, evt.getX(), evt.getY());
                return;
            }
            if (node.getUserObject().toString().equals("Работа")) {
                jPopupMenu13.show(jTree1, evt.getX(), evt.getY());
                return;
            }
            if (node.getUserObject().toString().equals("Щиты")) {
                jPopupMenu14.show(jTree1, evt.getX(), evt.getY());
                return;
            }
        }

        if (node.getUserObject().getClass() == obj_Specs.class) {
            //jPopupMenu4.show(jTree1, evt.getX(), evt.getY());
            return;
        }

        if (node.getUserObject().getClass() == obj_Project.class) {
            //jPopupMenu5.show(jTree1, evt.getX(), evt.getY());
            return;
        }

        if (node.getUserObject().getClass() == obj_Objects.class) {
            //jPopupMenu8.show(jTree1, evt.getX(), evt.getY());
            return;
        }

        if (node.getUserObject().getClass() == obj_Bill.class) {
            jPopupMenu12.show(jTree1, evt.getX(), evt.getY());
            return;
        }

        if (node.getUserObject().getClass() == obj_Box.class) {
            jPopupMenu15.show(jTree1, evt.getX(), evt.getY());
            return;
        }

    }//GEN-LAST:event_jTree1MouseClicked

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        NewProjectDialog dlg = new NewProjectDialog(this, true);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 1;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        NewSpecsDialog dlg = new NewSpecsDialog(this, true, prj, 0);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 121;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem11ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        NewObject dlg = new NewObject(this, true, prj.k);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 131;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem11ActionPerformed

    private void jMenuItem18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem18ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        NewTZDialog dlg = new NewTZDialog(this, true, prj);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 111;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem18ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        NewSmetaDialog dlg = new NewSmetaDialog(this, true, prj, 0);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 112;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jTree1ValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jTree1ValueChanged
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }

        CardLayout cl = (CardLayout) jPanel2.getLayout();

        if (node.getUserObject().getClass() == String.class) {
            if (node.getUserObject().toString().equals("Проекты")) {
                cl.show(jPanel2, "root");
                return;
            }
            if (node.getUserObject().toString().equals("Техническое задание и сметы")) {
                cl.show(jPanel2, "tzs");
                return;
            }
            if (node.getUserObject().toString().equals("Оборудование")) {
                cl.show(jPanel2, "specs");
                return;
            }
            if (node.getUserObject().toString().equals("Оборудование объекта")) {
                cl.show(jPanel2, "objspecs");
                return;
            }
            if (node.getUserObject().toString().equals("Объекты")) {
                cl.show(jPanel2, "objects");
                return;
            }
            if (node.getUserObject().toString().equals("Счета")) {
                cl.show(jPanel2, "bills");
                return;
            }
            if (node.getUserObject().toString().equals("Ведомости")) {
                cl.show(jPanel2, "vedomosti");
                return;
            }
            if (node.getUserObject().toString().equals("Сметы объекта")) {
                cl.show(jPanel2, "objsmetas");
                return;
            }
            if (node.getUserObject().toString().equals("Работа")) {
                cl.show(jPanel2, "works");
                return;
            }
            if (node.getUserObject().toString().equals("Щиты")) {
                cl.show(jPanel2, "boxes");
                return;
            }
        }
        if (node.getUserObject().getClass() == obj_Project.class) {
            UpdateProjectPage((obj_Project) node.getUserObject());
            cl.show(jPanel2, "project");
            return;
        }
        if (node.getUserObject().getClass() == obj_TZ.class) {
            UpdateTZPage((obj_TZ) node.getUserObject());
            cl.show(jPanel2, "tz");
            return;
        }
        if (node.getUserObject().getClass() == obj_Smeta.class) {
            UpdateSmetaPage((obj_Smeta) node.getUserObject());
            cl.show(jPanel2, "smeta");
            return;
        }
        if (node.getUserObject().getClass() == obj_Specs.class) {
            UpdateSpecPage((obj_Specs) node.getUserObject());
            cl.show(jPanel2, "spec");
            return;
        }
        if (node.getUserObject().getClass() == obj_Bill.class) {
            UpdateBillPage((obj_Bill) node.getUserObject());
            cl.show(jPanel2, "bill");
            return;
        }
        if (node.getUserObject().getClass() == obj_TTN.class) {
            UpdateTTNPage((obj_TTN) node.getUserObject());
            cl.show(jPanel2, "ttn");
            return;
        }
        if (node.getUserObject().getClass() == obj_Vedomost.class) {
            UpdateVedomostPage((obj_Vedomost) node.getUserObject());
            cl.show(jPanel2, "vedomost");
            return;
        }
        if (node.getUserObject().getClass() == obj_Objects.class) {
            UpdateObjectPage((obj_Objects) node.getUserObject());
            cl.show(jPanel2, "object");
            return;
        }
        if (node.getUserObject().getClass() == obj_Shema.class) {
            UpdateShemaPage((obj_Shema) node.getUserObject());
            cl.show(jPanel2, "shema");
            return;
        }
        if (node.getUserObject().getClass() == obj_Box.class) {
            UpdateBoxPage((obj_Box) node.getUserObject());
            cl.show(jPanel2, "box");
            return;
        }
        if (node.getUserObject().getClass() == obj_Draw.class) {
            UpdateDrawPage((obj_Draw) node.getUserObject());
            cl.show(jPanel2, "draw");
            return;
        }
    }//GEN-LAST:event_jTree1ValueChanged

    private void UpdateProjectPage(obj_Project prj) {
        jTextField2.setText(prj.name);
        jTextField3.setText(prj.address);
        jTextField4.setText("№" + prj.number + " (" + prj.code + ") от " + new SimpleDateFormat("dd.MM.yyyy").format(prj.founddate.getTime()) + " г.");
        jTextField5.setText("Цена договора: " + prj.cost);
        if (prj.prepaydate.getTimeInMillis() < 0 || prj.prepay.length() == 0) {
            jTextField6.setText("Предоплата не внесена");
        } else {
            jTextField6.setText("Предоплата: " + prj.prepay + ", внесена " + new SimpleDateFormat("dd.MM.yyyy").format(prj.prepaydate.getTime()) + " г.");
        }
        if (prj.doclink.length() == 0) {
            jButton1.setText("Текст договора не доступен");
            jButton1.setEnabled(false);
            jTextField12.setText("");
        } else {
            jButton1.setText("Открыть текст договора");
            jButton1.setEnabled(true);
            jTextField12.setText("(" + Vars.getFileNameFromString(prj.doclink).substring(1) + ")");
        }
        jTextArea1.setText(prj.notes);
    }

    private void UpdateTZPage(obj_TZ tz) {
        jTextField8.setText(tz.name);
        jTextArea2.setText(tz.notes);
        if (tz.doclink.length() == 0) {
            jButton5.setText("Файл технического задания не доступен");
            jButton5.setEnabled(false);
            jTextField13.setText("");
        } else {
            jButton5.setText("Открыть файл технического задания");
            jButton5.setEnabled(true);
            jTextField13.setText("(" + Vars.getFileNameFromString(tz.doclink).substring(1) + ")");
        }
    }

    private void UpdateSmetaPage(obj_Smeta smeta) {
        jTextField10.setText(smeta.name);
        jTextArea3.setText(smeta.notes);
        if (smeta.doclink.length() == 0) {
            jButton8.setText("Файл сметы не доступен");
            jButton8.setEnabled(false);
            jTextField14.setText("");
        } else {
            jButton8.setText("Открыть файл сметы");
            jButton8.setEnabled(true);
            jTextField14.setText("(" + Vars.getFileNameFromString(smeta.doclink).substring(1) + ")");
        }
    }

    private void UpdateSpecPage(obj_Specs specs) {
        jTextField15.setText(specs.name);
        jTextArea4.setText(specs.notes);
        if (specs.doclink.length() == 0) {
            jButton11.setText("Файл спецификации не доступен");
            jButton11.setEnabled(false);
            jTextField16.setText("");
        } else {
            jButton11.setText("Открыть файл спецификации");
            jButton11.setEnabled(true);
            jTextField16.setText("(" + Vars.getFileNameFromString(specs.doclink).substring(1) + ")");
        }
    }

    private void UpdateBillPage(obj_Bill bill) {
        jTextField18.setText(bill.name);
        jTextArea5.setText(bill.notes);
        if (bill.doclink.length() == 0) {
            jButton14.setText("Файл счета не доступен");
            jButton14.setEnabled(false);
            jTextField19.setText("");
        } else {
            jButton14.setText("Открыть файл счета");
            jButton14.setEnabled(true);
            jTextField19.setText("(" + Vars.getFileNameFromString(bill.doclink).substring(1) + ")");
        }
    }

    private void UpdateTTNPage(obj_TTN ttn) {
        jTextField21.setText(ttn.name);
        jTextArea6.setText(ttn.notes);
        if (ttn.doclink.length() == 0) {
            jButton17.setText("Файл ТТН не доступен");
            jButton17.setEnabled(false);
            jTextField22.setText("");
        } else {
            jButton17.setText("Открыть файл ТТН");
            jButton17.setEnabled(true);
            jTextField22.setText("(" + Vars.getFileNameFromString(ttn.doclink).substring(1) + ")");
        }
    }

    private void UpdateVedomostPage(obj_Vedomost vedomost) {
        jTextField24.setText(vedomost.name);
        jTextArea7.setText(vedomost.notes);
        if (vedomost.doclink.length() == 0) {
            jButton20.setText("Файл ведомости не доступен");
            jButton20.setEnabled(false);
            jTextField25.setText("");
        } else {
            jButton20.setText("Открыть файл ведомости");
            jButton20.setEnabled(true);
            jTextField25.setText("(" + Vars.getFileNameFromString(vedomost.doclink).substring(1) + ")");
        }
    }

    private void UpdateObjectPage(obj_Objects obj) {
        jTextField27.setText(obj.name);
        jTextArea8.setText(obj.notes);
    }

    private void UpdateShemaPage(obj_Shema shema) {
        jTextField28.setText(shema.name);
        jTextArea9.setText(shema.notes);
        if (shema.doclink.length() == 0) {
            jButton23.setText("Файл схемы не доступен");
            jButton23.setEnabled(false);
            jTextField30.setText("");
        } else {
            jButton23.setText("Открыть файл схемы");
            jButton23.setEnabled(true);
            jTextField30.setText("(" + Vars.getFileNameFromString(shema.doclink).substring(1) + ")");
        }
    }

    private void UpdateBoxPage(obj_Box box) {
        jTextField32.setText(box.name);
        jTextArea10.setText(box.notes);
        if (box.doclink.length() == 0) {
            jButton28.setText("Фото щита не доступно");
            jButton28.setEnabled(false);
            jTextField33.setText("");
        } else {
            jButton28.setText("Открыть фото щита");
            jButton28.setEnabled(true);
            jTextField33.setText("(" + Vars.getFileNameFromString(box.doclink).substring(1) + ")");
        }
    }

    private void UpdateDrawPage(obj_Draw draw) {
        jTextField35.setText(draw.name);
        jTextArea11.setText(draw.notes);
        if (draw.doclink.length() == 0) {
            jButton31.setText("Файл чертежа не доступен");
            jButton31.setEnabled(false);
            jTextField36.setText("");
        } else {
            jButton31.setText("Открыть чертеж");
            jButton31.setEnabled(true);
            jTextField36.setText("(" + Vars.getFileNameFromString(draw.doclink).substring(1) + ")");
        }
    }

    private void jMenuItem21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem21ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Objects obj = (obj_Objects) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        NewSmetaDialog dlg = new NewSmetaDialog(this, true, prj, obj.k);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 112;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem21ActionPerformed

    private void jMenuItem26ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem26ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Objects obj = (obj_Objects) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        NewSpecsDialog dlg = new NewSpecsDialog(this, true, prj, obj.k);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 121;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem26ActionPerformed

    private void jMenuItem29ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem29ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Specs spc = (obj_Specs) node.getUserObject();
        if (spc.objectid.equals(0)) {
            node = (DefaultMutableTreeNode) node.getParent().getParent();
        } else {
            node = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        NewBillDialog dlg = new NewBillDialog(this, true, spc.k, prj);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 12111;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem29ActionPerformed

    private void jMenuItem30ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem30ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Specs spc = (obj_Specs) node.getUserObject();
        if (spc.objectid.equals(0)) {
            node = (DefaultMutableTreeNode) node.getParent().getParent();
        } else {
            node = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        NewVedomostDialog dlg = new NewVedomostDialog(this, true, spc.k, prj);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 12121;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem30ActionPerformed

    private void jMenuItem31ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem31ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Bill bill = (obj_Bill) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent();
        obj_Specs spc = (obj_Specs) node.getUserObject();
        if (spc.objectid.equals(0)) {
            node = (DefaultMutableTreeNode) node.getParent().getParent();
        } else
        {
            node = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        NewTTNDialog dlg = new NewTTNDialog(this, true, bill.k, prj);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 121111;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem31ActionPerformed

    private void jMenuItem32ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem32ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Objects obj = (obj_Objects) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        NewShemaDialog dlg = new NewShemaDialog(this, true, obj.k, prj);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 13131;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem32ActionPerformed

    private void jMenuItem33ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem33ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        node = (DefaultMutableTreeNode) node.getParent();
        obj_Objects obj = (obj_Objects) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        NewBoxDialog dlg = new NewBoxDialog(this, true, obj.k, prj);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 13141;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem33ActionPerformed

    private void jMenuItem34ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem34ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Box box = (obj_Box) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        NewDrawDialog dlg = new NewDrawDialog(this, true, box.k, box.objectid, prj);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 131411;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem34ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + prj.doclink);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        jTextField1.setText("");
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        NewTZDialog dlg = new NewTZDialog(this, true, prj);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!dlg.retVal.equals(0)) {
            itemSelected.itemType = 111;
            itemSelected.itemID = dlg.retVal;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_TZ tz = (obj_TZ) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + tz.doclink);
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Smeta smeta = (obj_Smeta) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + smeta.doclink);
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить это техническое задание?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_TZ tz = (obj_TZ) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE tzs SET `hide` = true WHERE k = " + tz.k.toString());
            itemSelected.itemType = 11;
            itemSelected.itemID = tz.projectid;
            RefreshProjects();
        }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        jPopupMenu16.show(jButton3, jButton3.getMousePosition().x, jButton3.getMousePosition().y);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить этот проект?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_Project prj = (obj_Project) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE projects SET `hide` = true WHERE k = " + prj.k.toString());
            itemSelected.itemType = 0;
            itemSelected.itemID = 0;
            RefreshProjects();
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        jPopupMenu17.show(jButton6, jButton6.getMousePosition().x, jButton6.getMousePosition().y);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jMenuItem36ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem36ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_TZ tz = (obj_TZ) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, tz.name, "Переименовать", "Название технического задания:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!tz.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE tzs SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + tz.k.toString());
            itemSelected.itemType = 111;
            itemSelected.itemID = tz.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem36ActionPerformed

    private void jMenuItem37ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem37ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_TZ tz = (obj_TZ) node.getUserObject();
        DefaultMutableTreeNode pnode = (DefaultMutableTreeNode) node.getParent().getParent();
        obj_Project prj = (obj_Project) pnode.getUserObject();
        if (tz.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        JFileChooser jfc = new JFileChooser();
        if (jfc.showOpenDialog(this) == JFileChooser.CANCEL_OPTION) {
            return;
        }

        String doclink = jfc.getSelectedFile().getPath();
        if (doclink.length() > 0) {
            File dir = new File(Vars.prop.getProperty("Filestore") + File.separator + Vars.getHexString(prj.name).replace("|", "_") + File.separator + "Technical project and Estimate");
            if (!dir.exists()) {
                dir.mkdirs();
            }
            doclink = Vars.getHexString(prj.name).replace("|", "_") + File.separator + "Technical project and Estimate" + Vars.getFileNameFromString(doclink);
            if (!Vars.CopyFile(jfc.getSelectedFile().getPath(), Vars.prop.getProperty("Filestore") + File.separator + doclink)) {
                JOptionPane.showMessageDialog(null, "Ошибка копирования файла! Возможно неправильно указан путь.", "Внимание!", JOptionPane.WARNING_MESSAGE);
                return;
            }
        }

        DB db = new DB();
        db.executeNonQuery("UPDATE tzs SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + tz.k.toString());

        itemSelected.itemType = 111;
        itemSelected.itemID = tz.k;
        RefreshProjects();
    }//GEN-LAST:event_jMenuItem37ActionPerformed

    private void jMenuItem38ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem38ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_TZ tz = (obj_TZ) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, tz.notes, "Примечания", "Примечания к техническому заданию:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!tz.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE tzs SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + tz.k.toString());
            itemSelected.itemType = 111;
            itemSelected.itemID = tz.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem38ActionPerformed

    private void jMenuItem16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem16ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, prj.name, "Переименовать", "Название проекта:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!prj.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE projects SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + prj.k.toString());
            itemSelected.itemType = 1;
            itemSelected.itemID = prj.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem16ActionPerformed

    private void jMenuItem35ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem35ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, prj.address, "Адрес", "Адрес:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!prj.address.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE projects SET `address` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + prj.k.toString());
            itemSelected.itemType = 1;
            itemSelected.itemID = prj.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem35ActionPerformed

    private void jMenuItem40ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem40ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, prj.notes, "Примечания", "Примечания к проекту:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!prj.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE projects SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + prj.k.toString());
            itemSelected.itemType = 1;
            itemSelected.itemID = prj.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem40ActionPerformed

    private void jMenuItem39ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem39ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        if (prj.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        JFileChooser jfc = new JFileChooser();
        if (jfc.showOpenDialog(this) == JFileChooser.CANCEL_OPTION) {
            return;
        }

        String doclink = jfc.getSelectedFile().getPath();
        if (doclink.length() > 0) {
            File dir = new File(Vars.prop.getProperty("Filestore") + File.separator + Vars.getHexString(prj.name).replace("|", "_") + File.separator + "Project text");
            if (!dir.exists()) {
                dir.mkdirs();
            }
            doclink = Vars.getHexString(prj.name).replace("|", "_") + File.separator + "Project text" + Vars.getFileNameFromString(doclink);
            if (!Vars.CopyFile(jfc.getSelectedFile().getPath(), Vars.prop.getProperty("Filestore") + File.separator + doclink)) {
                JOptionPane.showMessageDialog(null, "Ошибка копирования файла! Возможно неправильно указан путь.", "Внимание!", JOptionPane.WARNING_MESSAGE);
                return;
            }
        }

        DB db = new DB();
        db.executeNonQuery("UPDATE projects SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + prj.k.toString());

        itemSelected.itemType = 1;
        itemSelected.itemID = prj.k;
        RefreshProjects();
    }//GEN-LAST:event_jMenuItem39ActionPerformed

    private void jMenuItem41ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem41ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        EditDateCostDialog dlg = new EditDateCostDialog(this, true, prj.founddate, prj.prepaydate, prj.prepay, prj.cost);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);

        if (!dlg.founddate.equals(prj.founddate) || !dlg.prepaydate.equals(prj.prepaydate) ||
                !dlg.cost.equals(prj.cost) || !dlg.prepay.equals(prj.prepay)) {
            String s_founddate = DB.getDTString(dlg.founddate);
            String s_prepaydate;
            if (dlg.prepaydate.before(new GregorianCalendar(1900, 0, 1))) {
                s_prepaydate = "0000-00-00 00:00:00.0";
            } else {
                s_prepaydate = DB.getDTString(dlg.prepaydate);
            }
            String cost = Vars.getHexString(dlg.cost);
            String prepay = Vars.getHexString(dlg.prepay);

            DB db = new DB();
            db.executeNonQuery("UPDATE projects SET " +
                    "`founddate` = '" + s_founddate + "', " +
                    "`prepaydate` = '" + s_prepaydate + "', " +
                    "`cost` = '" + cost + "', " +
                    "`prepay` = '" + prepay + "' " +
                    "WHERE k = " + prj.k.toString());

            itemSelected.itemType = 1;
            itemSelected.itemID = prj.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem41ActionPerformed

    private void jMenuItem17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem17ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        Edit2StringDialog dlg = new Edit2StringDialog(this, true, prj.code, prj.number, "Шифр проекта:", "Номер договора:", "Шифр и номер");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);

        if (!dlg.StringToEdit1.equals(prj.code) || !dlg.StringToEdit2.equals(prj.number)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE projects SET " +
                    "`number` = '" + Vars.getHexString(dlg.StringToEdit2) + "', " +
                    "`code` = '" + Vars.getHexString(dlg.StringToEdit1) + "' " +
                    "WHERE k = " + prj.k.toString());

            itemSelected.itemType = 1;
            itemSelected.itemID = prj.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem17ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить эту смету?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_Smeta smeta = (obj_Smeta) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE smetas SET `hide` = true WHERE k = " + smeta.k.toString());

            if (smeta.objectid.equals(0)) {
                itemSelected.itemType = 11;
                itemSelected.itemID = smeta.projectid;
                RefreshProjects();
            } else {
                itemSelected.itemType = 1311;
                itemSelected.itemID = smeta.objectid;
                RefreshProjects();
            }
        }
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jMenuItem42ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem42ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Smeta smeta = (obj_Smeta) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, smeta.name, "Переименовать", "Название сметы:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!smeta.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE smetas SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + smeta.k.toString());
            itemSelected.itemType = 112;
            itemSelected.itemID = smeta.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem42ActionPerformed

    private void jMenuItem43ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem43ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Smeta smeta = (obj_Smeta) node.getUserObject();

        if (smeta.objectid.equals(0)) {
            node = (DefaultMutableTreeNode) node.getParent().getParent();
        } else {
            node = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        }

        obj_Project prj = (obj_Project) node.getUserObject();
        if (smeta.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        String doclink;
        if (smeta.objectid.equals(0)) {
            doclink = ReFile(prj.name, "Technical project and Estimate");
        } else {
            doclink = ReFile(prj.name, "Objects_" + smeta.objectid);
        }
        if (doclink != null) {
            DB db = new DB();
            db.executeNonQuery("UPDATE smetas SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + smeta.k.toString());

            itemSelected.itemType = 112;
            itemSelected.itemID = smeta.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem43ActionPerformed

    private void jMenuItem44ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem44ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Smeta smeta = (obj_Smeta) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, smeta.notes, "Примечания", "Примечания к смете:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!smeta.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE smetas SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + smeta.k.toString());
            itemSelected.itemType = 112;
            itemSelected.itemID = smeta.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem44ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        jPopupMenu18.show(jButton9, jButton9.getMousePosition().x, jButton9.getMousePosition().y);
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Specs specs = (obj_Specs) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + specs.doclink);
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        jPopupMenu19.show(jButton12, jButton12.getMousePosition().x, jButton12.getMousePosition().y);
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить эту спецификацию оборудования?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_Specs specs = (obj_Specs) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE specs SET `hide` = true WHERE k = " + specs.k.toString());
            if (specs.objectid.equals(0)) {
                itemSelected.itemType = 12;
                itemSelected.itemID = specs.projectid;
            } else {
                itemSelected.itemType = 1312;
                itemSelected.itemID = specs.objectid;
            }
            RefreshProjects();

        }
    }//GEN-LAST:event_jButton13ActionPerformed

    private void jMenuItem45ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem45ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Specs specs = (obj_Specs) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, specs.name, "Переименовать", "Название спецификации:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!specs.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE specs SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + specs.k.toString());
            itemSelected.itemType = 121;
            itemSelected.itemID = specs.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem45ActionPerformed

    private void jMenuItem46ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem46ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Specs specs = (obj_Specs) node.getUserObject();
        if (specs.objectid.equals(0)) {
            node = (DefaultMutableTreeNode) node.getParent().getParent();
        } else {
            node = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        }

        obj_Project prj = (obj_Project) node.getUserObject();
        if (specs.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        String doclink = ReFile(prj.name, "Hardware");
        if (doclink != null) {
            DB db = new DB();
            db.executeNonQuery("UPDATE specs SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + specs.k.toString());
            itemSelected.itemType = 121;
            itemSelected.itemID = specs.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem46ActionPerformed

    // Копирует файл и возвращает новый doclink
    private String ReFile(String projname, String subdirname) {
        JFileChooser jfc = new JFileChooser();
        if (jfc.showOpenDialog(this) == JFileChooser.CANCEL_OPTION) {
            return null;
        }

        String doclink = jfc.getSelectedFile().getPath();
        if (doclink.length() > 0) {
            File dir = new File(Vars.prop.getProperty("Filestore") + File.separator + Vars.getHexString(projname).replace("|", "_") + File.separator + subdirname);
            if (!dir.exists()) {
                dir.mkdirs();
            }
            doclink = Vars.getHexString(projname).replace("|", "_") + File.separator + subdirname + Vars.getFileNameFromString(doclink);
            if (!Vars.CopyFile(jfc.getSelectedFile().getPath(), Vars.prop.getProperty("Filestore") + File.separator + doclink)) {
                JOptionPane.showMessageDialog(null, "Ошибка копирования файла! Возможно неправильно указан путь.", "Внимание!", JOptionPane.WARNING_MESSAGE);
                return null;
            }
        }

        return doclink;
    }

    private void jMenuItem47ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem47ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Specs specs = (obj_Specs) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, specs.notes, "Примечания", "Примечания к спецификации оборудования:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!specs.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE specs SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + specs.k.toString());
            itemSelected.itemType = 121;
            itemSelected.itemID = specs.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem47ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Bill bill = (obj_Bill) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + bill.doclink);
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
        jPopupMenu20.show(jButton15, jButton15.getMousePosition().x, jButton15.getMousePosition().y);
    }//GEN-LAST:event_jButton15ActionPerformed

    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить этот счет?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_Bill bill = (obj_Bill) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE bills SET `hide` = true WHERE k = " + bill.k.toString());
            itemSelected.itemType = 1211;
            itemSelected.itemID = bill.specid;
            RefreshProjects();
        }
    }//GEN-LAST:event_jButton16ActionPerformed

    private void jMenuItem48ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem48ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Bill bill = (obj_Bill) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, bill.name, "Переименовать", "Название счета:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!bill.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE bills SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + bill.k.toString());
            itemSelected.itemType = 12111;
            itemSelected.itemID = bill.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem48ActionPerformed

    private void jMenuItem49ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem49ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Bill bill = (obj_Bill) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent();
        obj_Specs spc = (obj_Specs) node.getUserObject();
        if (spc.objectid.equals(0)) {
            node = (DefaultMutableTreeNode) node.getParent().getParent();
        } else {
            node = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        if (bill.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        String doclink = ReFile(prj.name, "Hardware");
        if (doclink != null) {
            DB db = new DB();
            db.executeNonQuery("UPDATE bills SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + bill.k.toString());
            itemSelected.itemType = 12111;
            itemSelected.itemID = bill.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem49ActionPerformed

    private void jMenuItem50ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem50ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Bill bill = (obj_Bill) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, bill.notes, "Примечания", "Примечания к счету:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!bill.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE bills SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + bill.k.toString());
            itemSelected.itemType = 12111;
            itemSelected.itemID = bill.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem50ActionPerformed

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_TTN ttn = (obj_TTN) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + ttn.doclink);
    }//GEN-LAST:event_jButton17ActionPerformed

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
        jPopupMenu21.show(jButton18, jButton18.getMousePosition().x, jButton18.getMousePosition().y);
    }//GEN-LAST:event_jButton18ActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить эту ТТН?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_TTN ttn = (obj_TTN) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE ttn SET `hide` = true WHERE k = " + ttn.k.toString());
            itemSelected.itemType = 12111;
            itemSelected.itemID = ttn.billid;
            RefreshProjects();
        }
    }//GEN-LAST:event_jButton19ActionPerformed

    private void jMenuItem51ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem51ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_TTN ttn = (obj_TTN) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, ttn.name, "Переименовать", "Название ТТН:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!ttn.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE ttn SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + ttn.k.toString());
            itemSelected.itemType = 121111;
            itemSelected.itemID = ttn.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem51ActionPerformed

    private void jMenuItem52ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem52ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_TTN ttn = (obj_TTN) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent().getParent();
        obj_Specs spc = (obj_Specs) node.getUserObject();
        if (spc.objectid.equals(0)) {
            node = (DefaultMutableTreeNode) node.getParent().getParent();
        } else {
            node = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        if (ttn.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        String doclink = ReFile(prj.name, "Hardware");
        if (doclink != null) {
            DB db = new DB();
            db.executeNonQuery("UPDATE ttn SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + ttn.k.toString());
            itemSelected.itemType = 121111;
            itemSelected.itemID = ttn.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem52ActionPerformed

    private void jMenuItem53ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem53ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_TTN ttn = (obj_TTN) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, ttn.notes, "Примечания", "Примечания к ТТН:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!ttn.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE ttn SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + ttn.k.toString());
            itemSelected.itemType = 121111;
            itemSelected.itemID = ttn.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem53ActionPerformed

    private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton20ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Vedomost vedomost = (obj_Vedomost) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + vedomost.doclink);
    }//GEN-LAST:event_jButton20ActionPerformed

    private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
        jPopupMenu22.show(jButton21, jButton21.getMousePosition().x, jButton21.getMousePosition().y);
    }//GEN-LAST:event_jButton21ActionPerformed

    private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить эту ведомость?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_Vedomost vedomost = (obj_Vedomost) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE vedomosti SET `hide` = true WHERE k = " + vedomost.k.toString());
            itemSelected.itemType = 1212;
            itemSelected.itemID = vedomost.specid;
            RefreshProjects();
        }
    }//GEN-LAST:event_jButton22ActionPerformed

    private void jMenuItem54ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem54ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Vedomost vedomost = (obj_Vedomost) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, vedomost.name, "Переименовать", "Название ведомости:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!vedomost.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE vedomosti SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + vedomost.k.toString());
            itemSelected.itemType = 12121;
            itemSelected.itemID = vedomost.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem54ActionPerformed

    private void jMenuItem55ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem55ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Vedomost vedomost = (obj_Vedomost) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent();
        obj_Specs spc = (obj_Specs) node.getUserObject();
        if (spc.objectid.equals(0)) {
            node = (DefaultMutableTreeNode) node.getParent().getParent();
        } else {
            node = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        }
        obj_Project prj = (obj_Project) node.getUserObject();
        if (vedomost.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        String doclink = ReFile(prj.name, "Hardware");
        if (doclink != null) {
            DB db = new DB();
            db.executeNonQuery("UPDATE vedomosti SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + vedomost.k.toString());
            itemSelected.itemType = 12121;
            itemSelected.itemID = vedomost.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem55ActionPerformed

    private void jMenuItem56ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem56ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Vedomost vedomost = (obj_Vedomost) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, vedomost.notes, "Примечания", "Примечания к ведомости смонтированного оборудования:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!vedomost.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE vedomosti SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + vedomost.k.toString());
            itemSelected.itemType = 12121;
            itemSelected.itemID = vedomost.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem56ActionPerformed

    private void jButton24ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton24ActionPerformed
        jPopupMenu23.show(jButton24, jButton24.getMousePosition().x, jButton24.getMousePosition().y);
    }//GEN-LAST:event_jButton24ActionPerformed

    private void jButton25ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton25ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить этот объект?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_Objects obj = (obj_Objects) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE objects SET `hide` = true WHERE k = " + obj.k.toString());
            itemSelected.itemType = 13;
            itemSelected.itemID = obj.projectid;
            RefreshProjects();
        }
    }//GEN-LAST:event_jButton25ActionPerformed

    private void jMenuItem57ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem57ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Objects obj = (obj_Objects) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, obj.name, "Переименовать", "Название объекта:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!obj.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE objects SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + obj.k.toString());
            itemSelected.itemType = 131;
            itemSelected.itemID = obj.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem57ActionPerformed

    private void jMenuItem59ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem59ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Objects obj = (obj_Objects) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, obj.notes, "Примечания", "Примечания к объекту:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!obj.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE objects SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + obj.k.toString());
            itemSelected.itemType = 131;
            itemSelected.itemID = obj.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem59ActionPerformed

    private void jButton23ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton23ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Shema shema = (obj_Shema) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + shema.doclink);
    }//GEN-LAST:event_jButton23ActionPerformed

    private void jButton26ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton26ActionPerformed
        jPopupMenu24.show(jButton26, jButton26.getMousePosition().x, jButton26.getMousePosition().y);
    }//GEN-LAST:event_jButton26ActionPerformed

    private void jButton27ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton27ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить эту схему?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_Shema shema = (obj_Shema) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE shemas SET `hide` = true WHERE k = " + shema.k.toString());
            itemSelected.itemType = 1313;
            itemSelected.itemID = shema.objectid;
            RefreshProjects();
        }
    }//GEN-LAST:event_jButton27ActionPerformed

    private void jMenuItem58ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem58ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Shema shema = (obj_Shema) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, shema.name, "Переименовать", "Название схемы:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!shema.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE shemas SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + shema.k.toString());
            itemSelected.itemType = 13131;
            itemSelected.itemID = shema.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem58ActionPerformed

    private void jMenuItem60ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem60ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Shema shema = (obj_Shema) node.getUserObject();
        DefaultMutableTreeNode pnode = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        obj_Project prj = (obj_Project) pnode.getUserObject();
        if (shema.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        String doclink = ReFile(prj.name, "Objects_" + shema.objectid.toString());
        if (doclink != null) {
            DB db = new DB();
            db.executeNonQuery("UPDATE shemas SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + shema.k.toString());
            itemSelected.itemType = 13131;
            itemSelected.itemID = shema.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem60ActionPerformed

    private void jMenuItem61ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem61ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Shema shema = (obj_Shema) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, shema.notes, "Примечания", "Примечания к схеме:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!shema.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE shemas SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + shema.k.toString());
            itemSelected.itemType = 13131;
            itemSelected.itemID = shema.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem61ActionPerformed

    private void jButton28ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton28ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Box box = (obj_Box) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + box.doclink);
    }//GEN-LAST:event_jButton28ActionPerformed

    private void jButton29ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton29ActionPerformed
        jPopupMenu25.show(jButton29, jButton29.getMousePosition().x, jButton29.getMousePosition().y);
    }//GEN-LAST:event_jButton29ActionPerformed

    private void jButton30ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton30ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить этот щит?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_Box box = (obj_Box) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE boxes SET `hide` = true WHERE k = " + box.k.toString());
            itemSelected.itemType = 1314;
            itemSelected.itemID = box.objectid;
            RefreshProjects();
        }
    }//GEN-LAST:event_jButton30ActionPerformed

    private void jMenuItem62ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem62ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Box box = (obj_Box) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, box.name, "Переименовать", "Название щита:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!box.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE boxes SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + box.k.toString());
            itemSelected.itemType = 13141;
            itemSelected.itemID = box.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem62ActionPerformed

    private void jMenuItem63ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem63ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Box box = (obj_Box) node.getUserObject();
        DefaultMutableTreeNode pnode = (DefaultMutableTreeNode) node.getParent().getParent().getParent().getParent();
        obj_Project prj = (obj_Project) pnode.getUserObject();
        if (box.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        String doclink = ReFile(prj.name, "Objects_" + box.objectid);
        if (doclink != null) {
            DB db = new DB();
            db.executeNonQuery("UPDATE boxes SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + box.k.toString());
            itemSelected.itemType = 13141;
            itemSelected.itemID = box.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem63ActionPerformed

    private void jMenuItem64ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem64ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Box box = (obj_Box) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, box.notes, "Примечания", "Примечания к щиту:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!box.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE boxes SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + box.k.toString());
            itemSelected.itemType = 13141;
            itemSelected.itemID = box.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem64ActionPerformed

    private void jButton31ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton31ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Draw draw = (obj_Draw) node.getUserObject();
        Vars.OpenFile(Vars.prop.getProperty("Filestore") + File.separator + draw.doclink);
    }//GEN-LAST:event_jButton31ActionPerformed

    private void jButton32ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton32ActionPerformed
        jPopupMenu26.show(jButton32, jButton32.getMousePosition().x, jButton32.getMousePosition().y);
    }//GEN-LAST:event_jButton32ActionPerformed

    private void jButton33ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton33ActionPerformed
        if (JOptionPane.showConfirmDialog(
                null,
                "Вы уверены, что хотите удалить этот чертеж?",
                "Подтверждение",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
            if (node == null) {
                return;
            }
            obj_Draw draw = (obj_Draw) node.getUserObject();
            DB db = new DB();
            db.executeNonQuery("UPDATE draws SET `hide` = true WHERE k = " + draw.k.toString());
            itemSelected.itemType = 13141;
            itemSelected.itemID = draw.boxid;
            RefreshProjects();
        }
    }//GEN-LAST:event_jButton33ActionPerformed

    private void jMenuItem65ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem65ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Draw draw = (obj_Draw) node.getUserObject();
        EditStringDialog dlg = new EditStringDialog(this, true, draw.name, "Переименовать", "Название чертежа:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!draw.name.equals(dlg.StringToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE draws SET `name` = '" + Vars.getHexString(dlg.StringToEdit) + "' WHERE k = " + draw.k.toString());
            itemSelected.itemType = 131411;
            itemSelected.itemID = draw.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem65ActionPerformed

    private void jMenuItem66ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem66ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Draw draw = (obj_Draw) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent().getParent();
        obj_Objects obj = (obj_Objects) node.getUserObject();
        node = (DefaultMutableTreeNode) node.getParent().getParent();
        obj_Project prj = (obj_Project) node.getUserObject();
        if (draw.doclink.length() > 0) {
            if (JOptionPane.showConfirmDialog(
                    null,
                    "Файл уже прикреплен. Хотите прикрепить другой?",
                    "Подтверждение",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
                return;
            }
        }

        String doclink = ReFile(prj.name, "Objects_" + obj.k);
        if (doclink != null) {
            DB db = new DB();
            db.executeNonQuery("UPDATE draws SET `doclink` = '" + Vars.getHexString(doclink) + "' WHERE k = " + draw.k.toString());
            itemSelected.itemType = 131411;
            itemSelected.itemID = draw.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem66ActionPerformed

    private void jMenuItem67ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem67ActionPerformed
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
        if (node == null) {
            return;
        }
        obj_Draw draw = (obj_Draw) node.getUserObject();
        EditTextDialog dlg = new EditTextDialog(this, true, draw.notes, "Примечания", "Примечания к чертежу:");
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (!draw.notes.equals(dlg.TextToEdit)) {
            DB db = new DB();
            db.executeNonQuery("UPDATE draws SET `notes` = '" + Vars.getHexString(dlg.TextToEdit) + "' WHERE k = " + draw.k.toString());
            itemSelected.itemType = 131411;
            itemSelected.itemID = draw.k;
            RefreshProjects();
        }
    }//GEN-LAST:event_jMenuItem67ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        AboutDialog dlg = new AboutDialog(this, true);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton20;
    private javax.swing.JButton jButton21;
    private javax.swing.JButton jButton22;
    private javax.swing.JButton jButton23;
    private javax.swing.JButton jButton24;
    private javax.swing.JButton jButton25;
    private javax.swing.JButton jButton26;
    private javax.swing.JButton jButton27;
    private javax.swing.JButton jButton28;
    private javax.swing.JButton jButton29;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton30;
    private javax.swing.JButton jButton31;
    private javax.swing.JButton jButton32;
    private javax.swing.JButton jButton33;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JMenuItem jMenuItem16;
    private javax.swing.JMenuItem jMenuItem17;
    private javax.swing.JMenuItem jMenuItem18;
    private javax.swing.JMenuItem jMenuItem19;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem20;
    private javax.swing.JMenuItem jMenuItem21;
    private javax.swing.JMenuItem jMenuItem22;
    private javax.swing.JMenuItem jMenuItem23;
    private javax.swing.JMenuItem jMenuItem24;
    private javax.swing.JMenuItem jMenuItem25;
    private javax.swing.JMenuItem jMenuItem26;
    private javax.swing.JMenuItem jMenuItem27;
    private javax.swing.JMenuItem jMenuItem28;
    private javax.swing.JMenuItem jMenuItem29;
    private javax.swing.JMenuItem jMenuItem30;
    private javax.swing.JMenuItem jMenuItem31;
    private javax.swing.JMenuItem jMenuItem32;
    private javax.swing.JMenuItem jMenuItem33;
    private javax.swing.JMenuItem jMenuItem34;
    private javax.swing.JMenuItem jMenuItem35;
    private javax.swing.JMenuItem jMenuItem36;
    private javax.swing.JMenuItem jMenuItem37;
    private javax.swing.JMenuItem jMenuItem38;
    private javax.swing.JMenuItem jMenuItem39;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem40;
    private javax.swing.JMenuItem jMenuItem41;
    private javax.swing.JMenuItem jMenuItem42;
    private javax.swing.JMenuItem jMenuItem43;
    private javax.swing.JMenuItem jMenuItem44;
    private javax.swing.JMenuItem jMenuItem45;
    private javax.swing.JMenuItem jMenuItem46;
    private javax.swing.JMenuItem jMenuItem47;
    private javax.swing.JMenuItem jMenuItem48;
    private javax.swing.JMenuItem jMenuItem49;
    private javax.swing.JMenuItem jMenuItem50;
    private javax.swing.JMenuItem jMenuItem51;
    private javax.swing.JMenuItem jMenuItem52;
    private javax.swing.JMenuItem jMenuItem53;
    private javax.swing.JMenuItem jMenuItem54;
    private javax.swing.JMenuItem jMenuItem55;
    private javax.swing.JMenuItem jMenuItem56;
    private javax.swing.JMenuItem jMenuItem57;
    private javax.swing.JMenuItem jMenuItem58;
    private javax.swing.JMenuItem jMenuItem59;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem60;
    private javax.swing.JMenuItem jMenuItem61;
    private javax.swing.JMenuItem jMenuItem62;
    private javax.swing.JMenuItem jMenuItem63;
    private javax.swing.JMenuItem jMenuItem64;
    private javax.swing.JMenuItem jMenuItem65;
    private javax.swing.JMenuItem jMenuItem66;
    private javax.swing.JMenuItem jMenuItem67;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JPopupMenu jPopupMenu10;
    private javax.swing.JPopupMenu jPopupMenu11;
    private javax.swing.JPopupMenu jPopupMenu12;
    private javax.swing.JPopupMenu jPopupMenu13;
    private javax.swing.JPopupMenu jPopupMenu14;
    private javax.swing.JPopupMenu jPopupMenu15;
    private javax.swing.JPopupMenu jPopupMenu16;
    private javax.swing.JPopupMenu jPopupMenu17;
    private javax.swing.JPopupMenu jPopupMenu18;
    private javax.swing.JPopupMenu jPopupMenu19;
    private javax.swing.JPopupMenu jPopupMenu2;
    private javax.swing.JPopupMenu jPopupMenu20;
    private javax.swing.JPopupMenu jPopupMenu21;
    private javax.swing.JPopupMenu jPopupMenu22;
    private javax.swing.JPopupMenu jPopupMenu23;
    private javax.swing.JPopupMenu jPopupMenu24;
    private javax.swing.JPopupMenu jPopupMenu25;
    private javax.swing.JPopupMenu jPopupMenu26;
    private javax.swing.JPopupMenu jPopupMenu3;
    private javax.swing.JPopupMenu jPopupMenu4;
    private javax.swing.JPopupMenu jPopupMenu5;
    private javax.swing.JPopupMenu jPopupMenu6;
    private javax.swing.JPopupMenu jPopupMenu7;
    private javax.swing.JPopupMenu jPopupMenu8;
    private javax.swing.JPopupMenu jPopupMenu9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator10;
    private javax.swing.JSeparator jSeparator11;
    private javax.swing.JSeparator jSeparator12;
    private javax.swing.JSeparator jSeparator13;
    private javax.swing.JSeparator jSeparator14;
    private javax.swing.JSeparator jSeparator15;
    private javax.swing.JSeparator jSeparator16;
    private javax.swing.JSeparator jSeparator17;
    private javax.swing.JSeparator jSeparator18;
    private javax.swing.JSeparator jSeparator19;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea10;
    private javax.swing.JTextArea jTextArea11;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JTextArea jTextArea3;
    private javax.swing.JTextArea jTextArea4;
    private javax.swing.JTextArea jTextArea5;
    private javax.swing.JTextArea jTextArea6;
    private javax.swing.JTextArea jTextArea7;
    private javax.swing.JTextArea jTextArea8;
    private javax.swing.JTextArea jTextArea9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField12;
    private javax.swing.JTextField jTextField13;
    private javax.swing.JTextField jTextField14;
    private javax.swing.JTextField jTextField15;
    private javax.swing.JTextField jTextField16;
    private javax.swing.JTextField jTextField17;
    private javax.swing.JTextField jTextField18;
    private javax.swing.JTextField jTextField19;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField20;
    private javax.swing.JTextField jTextField21;
    private javax.swing.JTextField jTextField22;
    private javax.swing.JTextField jTextField23;
    private javax.swing.JTextField jTextField24;
    private javax.swing.JTextField jTextField25;
    private javax.swing.JTextField jTextField26;
    private javax.swing.JTextField jTextField27;
    private javax.swing.JTextField jTextField28;
    private javax.swing.JTextField jTextField29;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField30;
    private javax.swing.JTextField jTextField31;
    private javax.swing.JTextField jTextField32;
    private javax.swing.JTextField jTextField33;
    private javax.swing.JTextField jTextField34;
    private javax.swing.JTextField jTextField35;
    private javax.swing.JTextField jTextField36;
    private javax.swing.JTextField jTextField37;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    private javax.swing.JTree jTree1;
    // End of variables declaration//GEN-END:variables
}
